SQL Error 1064: 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 'ORDER BY titulo_ca' at line 5 Query: SELECT r.id FROM gb_recetas r INNER JOIN gb_recetas_gb_articulos ra ON ra.fk_gb_recetas = r.id WHERE publicado = 1 AND ra.fk_gb_articulos = ORDER BY titulo_ca