Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

MySQL ORDER by Question

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

JsteRmX

Established Member
Impact
2
By default when you query the DB and have it display the selected data, it will just show it to you in the order it was entered into the database.... Meaning the first record will be the first in the list. I want to reverse this. I want the newest record to show on the top. What would I Order by in my sql query? I do not have a date added column in my database, so this is not really an option. And using Order by desc is for alphabetical order. I need it to just reverse the default way. Can anyone help? Thanks!

wow nevermind everyone. I found a solution. It jsut came to me right after posting my question.

I do have an ID field in my table, so i am just ordering by that, desc. So the last number (or really the newest one) appears on top.

:tu:
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
the id .
 
0
Close
select * from anytable order by id desc

hope it helps
 
0
Close
if you read his post fully you will see he already got his answer and posted it into the same post.
 
0
Close
Please note that the 'gaps' in the ID sequence may be reclaimed by mySQL or filled in manually. If you are looking for the true last added/updated record it may be a good idea to add a timestamp column and sort desc on it.
 
0
Close
wow nevermind everyone. I found a solution. It jsut came to me right after posting my question.

:)
 
0
Close
lol! just read the post halfly...sorry :D
 
0
Close
lol thanks for all the replies though.

I thought i posted that update to a REPLY, not in the same post! sorry guys! I guess that was kind of confusing. ..... i could have sworn i hit 'reply' though. hmmmmmm :-/ maybe i am going crazy, hehe.
 
0
Close
If you double post in the same day, it adds it to your previous post.
 
0
Close
oh I see, obviously I didnt know that... thanks for the info.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back