sql : select c.* from (( select count(*) as ntags, iw4_noticias.* from iw4_noticias where (titulo_es REGEXP '^.*([:space:]|[:punct:])?levi's([:space:]|[:punct:])?.*$') and (iw4fechapublicacion<20150705 or (iw4fechapublicacion=20150705 and hora<='00:25')) and publicar=1 and visible_es=1 group by iw4id ) UNION ( select count(n.iw4id) as ntags, n.* from iw4_noticias n, (select nt.id2 as iw4id from iw4_noticias_nn_tags nt where nt.id1='15127') t, iw4_noticias_nn_tags nnt where t.iw4id=nnt.id2 and n.iw4id=nnt.id1 and n.iw4id!='15127' and (n.iw4fechapublicacion<20150705 or (n.iw4fechapublicacion=20150705 and n.hora<='00:25')) and n.publicar=1 and n.visible_es=1 group by n.iw4id )) c where c.iw4id!=15127 order by c.ntags desc, c.iw4fechapublicacion desc limit 5

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 's([:space:]|[:punct:])?.*$') and
                    (iw4fechapublicacion<201507' at line 8