shirvo Posted February 11, 2007 Share Posted February 11, 2007 I have a table and in the id field i want to find out how many there are in it. The whole reason for this is because i want to find the highest 4 so i can display the 4 newest members. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 11, 2007 Share Posted February 11, 2007 Order the id column in descending order and limit the results by 4. That will grab the 4 newest members from your table. SELECT * from `members_tbl` ORDER By id DESC LIMIT 4 Quote Link to comment Share on other sites More sharing options...
trq Posted February 11, 2007 Share Posted February 11, 2007 Don't rely on an auto-incrementing primary key to determine the latest records (that is not there intended purpose, and it will prove unreliable), put a timestamp in your table then order by that with a limit of 4. eg; SELECT username FROM users ORDER BY tstamp DESC LIMIT 4; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.