You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 5select p.Id as PictureId, p.Name as PName, p.Link, p.Picture, p.PictureName, p.Loved ,p.DateAdded, u.Id as UId, u.UserName from _pictures p inner join _pictures_collections_rel rel on (p.Id=rel.PictureId) inner join _users u on (p.UserId=u.Id) where rel.CollectionId='' order by p.Id desc limit ,10