SELECT seo.idseo, seo.nombre_carpeta, c.ciudad, s.idads, s.empresa, s.whatsapp, s.imagen, d.distrito, s.telefono, s.direccion from seo_ads s, ubi_ciudad c, ubi_distrito d, seoweb seo WHERE s.idciudad=c.idciudad AND s.iddist=d.iddist and s.idseo=seo.idseo and s.estado=1 and s.idtipoa=4 and s.idseo=76 and d.iddist= order by s.idads - 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 s.idads' at line 1