SELECT * FROM categorias WHERE id_padre = AND id_categorias NOT IN (13,12,16,17,18,11) ORDER BY orden ASC 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 id_categorias NOT IN (13,12,16,17,18,11) ORDER BY orden ASC' at line 1