Simple query question
Moderator: General Moderators
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
Simple query question
How do i select 20 records, those that are added last to the database?
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Code: Select all
SELECT * FROM table ORDER BY record DESC LIMIT 20HTH somehow though
It's ASC. ASC = ascending = increasing; DESC = decending = decreasing.jayshields wrote:Supposing you've got an auto incrementing record as an ID in your DB or a date for each DB entry, change the field for 'record'. I don't know if it's ASC or DESC without trying it myself, I always get confused.Code: Select all
SELECT * FROM table ORDER BY record DESC LIMIT 20
HTH somehow though
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
yeah im stupid, but not that stupid 
i just forget which way it sorts dates sometimes
like if it was ascending would it show the oldest date last?
i just forget which way it sorts dates sometimes
Last edited by jayshields on Tue Nov 15, 2005 5:30 am, edited 1 time in total.