kjtocool Posted December 18, 2007 Share Posted December 18, 2007 Let's say I have a query like this: <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID"; ?> How do I modify that query so that it: A) Returns only the first 10 results. B) Returns only results 11 through 20. Quote Link to comment Share on other sites More sharing options...
kjtocool Posted December 18, 2007 Author Share Posted December 18, 2007 I believe this is the answer, if anyone can verify I'd appreciate it: A) <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID LIMIT 0,9"; ?> B) <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID LIMIT 10,9"; ?> Quote Link to comment Share on other sites More sharing options...
kopytko Posted December 18, 2007 Share Posted December 18, 2007 Almost. A) limit 0, 10 B) limit 10,10 Quote Link to comment Share on other sites More sharing options...
kjtocool Posted December 18, 2007 Author Share Posted December 18, 2007 So the second number starts at 1 and not 0? Thanks for the help. 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.