mardi 19 juillet 2016

Order by clause is not working with group by in sql query

MYSQL query is getting data exactly as I want.But ORDER BY clause is not working.

But when I removed the GROUP BY from query then ORDER BY clause is work.

SELECT MESS. * , US. * , LF. *
    FROM messages MESS
    LEFT JOIN users AS US ON US.id = MESS.to_id
    LEFT JOIN label_infos LF ON LF.user_id = MESS.to_id
    WHERE MESS.frm_id =27
    OR MESS.to_id =27
    GROUP BY US.id
    ORDER BY MESS.id DESC

Aucun commentaire:

Enregistrer un commentaire