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 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. 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. 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? Link to comment https://forums.phpfreaks.com/topic/179948-increment-mysql/#findComment-957444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.