I am querying data from a database through PHP. One column contains date values and another column contains interger values ranging from 1-99. How would I create a query or a function that will get 25 of the most recent dates, and then sort them by the second column (1-99), and then output just 4 of them. Thanks.
You could do something like in mysql. SELECT * FROM table ORDER BY dates_table DESC, int_table ASC LIMIT 4
But won't your query just get the four most recent dates and order them by the second column? I need a way to get 25 of the most recent dates ordering them by most recent and then by the second column and then outputing just 4. If there is no wAy inmysql to do this how do you think I could do it using php? Thanks!
select * from (SELECT * FROM table ORDER BY date_column DESC LIMIT 4) a order by a.numeric_column asc; This might work. Check it out.