CanMan2004 Posted September 20, 2006 Share Posted September 20, 2006 Hi allIs there a way to put something into a query which ignores the first defined number of results.For example, if I have the following query[code]SELECT * FROM mydata WHERE `name` = '".$name."' AND allowed = 'YES' ORDER BY `idnum` DESC LIMIT 20[/code]Is there a way to ignore the first x number of results which are returned.x is a number, so if your results brought back id numbers123456and you said for it to ignore the first 4, then it would return56Can this be done?Thanks in advanceEd Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 I think that was done with arrays() but a real good intresting quistion, Will be nice to see that done with the database. Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 20, 2006 Share Posted September 20, 2006 Yeah, you provide LIMIT with two arguments[color=green][b]LIMIT 4, 20[/b][/color]The first is the offset you want and the second is the amount of rows to return.It returns rows based on the offset of your dataset, not the entire table. So if you had the following data:ID, Name1 Rich2 Paul3 Sam4 Ryan5 Dave[color=maroon]SELECT name FROM table ORDER BY id LIMIT 1, 1[/color] you'd get Paul, but if you had SELECT name FROM table WHERE name LIKE 'R%' ORDER BY name LIMIT 1, 1 then you'd get Ryan.I hope that makes senseRegardsHuggie Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted September 20, 2006 Author Share Posted September 20, 2006 thank you 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.