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 orden ASC LIMIT 1' at line 1

SELECT p.id FROM productos p, categorias c WHERE publicada = 1 AND c.division_id = 4 AND c.id = p.categoria_id AND p.categoria_id = ORDER BY orden ASC LIMIT 1