COp COp - 4 months ago 12
PHP Question

PHP MYSQL ORDER BY DESC then ASC

I have got this MYSQL

SELECT * FROM chat WHERE To_='$NameId' OR From_='$NameId' ORDER BY `DATE` DESC LIMIT 0,50


This code returns me data in this order

1 newest
2 newest
3 newest
4 newest
5 newest

But i want data to be returned in this way

5 newest
4 newest
3 newest
2 newest
1 newest

How can i do that?

Answer

Use this :

SELECT * FROM (select * from chat where To_='$NameId' OR From_='$NameId' ORDER BY DATE DESC LIMIT 0,50) sub ORDER BY DATE ASC 
Comments