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 'AND excluido IN ('0','2') ORDER BY ordem LIMIT 1' at line 1 - SELECT `blog_img`.* FROM `blog_img` WHERE blogFK = AND excluido IN ('0','2') ORDER BY ordem LIMIT 1