Jump to content

Help with SQL Ordering in PHP


rach01

Recommended Posts

hello

 

I have a query which is long, but the main section I have a question about is

 

GROUP BY id ORDER BY id DESC LIMIT  10

 

this works ok and gives me the first 10 records in descending order, so it gets oldest to newest

 

what do I need to do, to keep the query (first 10 records) but order by newest to oldest

 

can anyone help me, I've searched high and low, and tried lots of ideas, but cannot get it to work right

 

thanxs

Link to comment
https://forums.phpfreaks.com/topic/279846-help-with-sql-ordering-in-php/
Share on other sites

Firstly, why are you grouping by ID when ID is, or at least should be, unique?

 

I'm not really convinced you've searched high and low as you've identified the ORDER BY is ordering your result set but haven't searched how to use it? The key word is DESC meaning descending. You'll want to change it to ASC meaning ascending.

 

Moreover, be patient for an answer. This forum has people contributing from all over the world with different time zones so just wait 24 hours and you should have an answer!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.