hasek522 Posted August 14, 2008 Share Posted August 14, 2008 What is the easiest way to select the last three entries in a SQL database? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 14, 2008 Share Posted August 14, 2008 Add ORDER BY column DESC LIMIT at the end of your query Quote Link to comment Share on other sites More sharing options...
hasek522 Posted August 14, 2008 Author Share Posted August 14, 2008 could you help me out a bit with that? Im pretty new to SQL. Right now I just have: $sql = "SELECT * FROM stylists"; would I change that to this? $sql = "SELECT * FROM stylists ORDER BY id DESC LIMIT=3"; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 14, 2008 Share Posted August 14, 2008 You're on the right path, you don't the = though it's $sql = "SELECT * FROM stylists ORDER BY id DESC LIMIT 3"; That will return the last three item (oldest) 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.