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 FechaSorteo DESC' at line 3 SELECT IdGanador, Nombre, Ciudad, Premio, Biografia, Foto, FechaSorteo FROM ganadores
INNER JOIN sorteos ON ganadores.IdSorteo = sorteos.IdSorteo
WHERE sorteos.IdJuego = ORDER BY FechaSorteo DESC;