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 o.publicado = 1 AND curdate() between o.f_desde and o.f_hasta UNION SELECT ' at line 1