perky416 Posted April 29, 2011 Share Posted April 29, 2011 Hi everyone, I have the following query to select things from my database table. Im also trying to get it for ignore the first 10 results, so that it selects everything from row 11 onwards. mysql_query("SELECT * FROM table ORDER BY date DESC LIMIT 10"); Does anybody know how I would achieve this? Thanks Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/ Share on other sites More sharing options...
JKG Posted April 29, 2011 Share Posted April 29, 2011 mysql_query("SELECT * FROM table ORDER BY date DESC LIMIT (10, 9999)"); you could return a numrows to change the 9999 to a real number. EDIT: select * isnt great, declare the columns you need. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1208137 Share on other sites More sharing options...
Pikachu2000 Posted April 29, 2011 Share Posted April 29, 2011 LIMIT 10, 10 EDIT: Didn't notice you wanted everything after the 10th record. In that case, I would probably count records in the loop, and just suppress the first 10 that are returned. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1208138 Share on other sites More sharing options...
perky416 Posted April 29, 2011 Author Share Posted April 29, 2011 Thanks guys i used the following: mysql_query("SELECT * FROM table ORDER BY date DESC LIMIT 10, 9999"); it didnt work with the brackets so i removed them and its perfect. thanks. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1208166 Share on other sites More sharing options...
perky416 Posted April 29, 2011 Author Share Posted April 29, 2011 Hi JKG, Just out of curiosity, what benefits would it give me by just selecting the columns that i need rather than selecting everything? I have wondered about this before. Thanks mate. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1208169 Share on other sites More sharing options...
Maq Posted April 29, 2011 Share Posted April 29, 2011 Because, it creates un-needed overhead when selecting * and if your table changes in the future, you will be selecting un-expected data. There are other reasons, but these are the primary ones. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1208173 Share on other sites More sharing options...
benanamen Posted October 17, 2015 Share Posted October 17, 2015 Hi JKG, Just out of curiosity, what benefits would it give me by just selecting the columns that i need rather than selecting everything? I have wondered about this before. Thanks mate. One other important benefit is you know what columns you are dealing with. If you come back to your code a year later or someone else reads the code, you will have to go look at the DB to see what is there or print_r the result. Aside from that selecting data you don't need by using * is just lazy. Link to comment https://forums.phpfreaks.com/topic/235081-ignore-first-10-rows/#findComment-1523567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.