Jump to content

Help with SQL Ordering in PHP


rach01
Go to solution Solved by Barand,

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
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!

Edited by cpd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.