error en query: SELECT s.idSector, s.Nombre, sp.IdPeriodo, sp.Activo FROM bef_Sector AS s Inner Join bef_SectorPeriodo AS sp ON s.idSector = sp.IdSector WHERE sp.Activo = 1 and s.idSector = 69 ​ ORDER BY sp.IdPeriodo desc LIMIT 1 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 sp.IdPeriodo desc LIMIT 1' at line 10