Ham Posted September 19, 2005 Share Posted September 19, 2005 I'm trying to return 10 rows from a table starting at a primary key id with this query: select * from table_name limit $primary_key, 10; ...but it does not work. Please show me how! Thanks, Ham Quote Link to comment https://forums.phpfreaks.com/topic/2537-using-limit/ Share on other sites More sharing options...
ryanlwh Posted September 19, 2005 Share Posted September 19, 2005 the limit x,y syntax only works with offsets (row number). If there was no deletions in your table, this would work fine, but if some items were deleted, an id would not be the correct offset anymore. maybe this is what you need: SELECT * FROM table_name WHERE id >= $primary_key ORDER BY id ASC LIMIT 10; Quote Link to comment https://forums.phpfreaks.com/topic/2537-using-limit/#findComment-8420 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.