dreamwest Posted November 2, 2009 Share Posted November 2, 2009 How can i create a query that selects (increments) the next row $next = $_GET['next']; $next = $next +1; //increment to the next row "SELECT * FROM red WHERE approve='1' and id='{$next}' " This is ok if the are no missing ids in the table 1 2 3 4 5 6 But will create a problem with this 1 2 5 6 Quote Link to comment https://forums.phpfreaks.com/topic/179948-increment-mysql/ Share on other sites More sharing options...
cags Posted November 2, 2009 Share Posted November 2, 2009 Sound like you should be using the LIMIT keyword to limit 1 result and set the offset. Quote Link to comment https://forums.phpfreaks.com/topic/179948-increment-mysql/#findComment-949313 Share on other sites More sharing options...
Mchl Posted November 2, 2009 Share Posted November 2, 2009 If you want query to have a column with row numbers you need to do it like this SET @rownum = 0; SELECT @rownum := @rownum + 1 AS rowNo, t.* FROM table AS t; These are two queries that have to be run one after another. Quote Link to comment https://forums.phpfreaks.com/topic/179948-increment-mysql/#findComment-949314 Share on other sites More sharing options...
fenway Posted November 14, 2009 Share Posted November 14, 2009 Why are you trying to do this? Quote Link to comment https://forums.phpfreaks.com/topic/179948-increment-mysql/#findComment-957444 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.