views:

49

answers:

4

Hi i have my mysql

$query = mysql_query('SELECT * from rbf_edades_news order by month DESC '.$limit.'');

month and day are in different fields,

any idea?"

is this possible

$query = mysql_query('SELECT * from rbf_edades_news order by month and DESC '.$limit.'');

Thanks!

+5  A: 

This will sort first by month and then by day:

$query = mysql_query('SELECT * from rbf_edades_news order by month DESC, day DESC '.$limit.'');
JochenJung
thanks for your help but still not sort...
devzone
what you get when you run this query ?
Haim Evgi
I modified the query to sort month as well as day in descending order (like in haim evig's example). It makes more sense to order both fields in the same direction.
JochenJung
+2  A: 

you can order by 2 columns like

$query = mysql_query('SELECT * from rbf_edades_news order by month DESC, day  DESC '.$limit.'');
Haim Evgi
+1  A: 

You can use order by with 2 field. This should work:

$query = mysql_query('SELECT * from rbf_edades_news order by month, day DESC '.$limit.'');
aniri
A: 

Hi,

No, your second query is not possible. DESC has to be next to a fieldname like in your first example and it is used to order your results by month in descending order. Use ASC for ascending order.

If you want to order by day and month, you can do the following:

SELECT * from rbf_edades_news order by day DESC, month DESC

One question, what is exactly the content of the $limit variable?

Ricardo