christa Posted July 19, 2010 Share Posted July 19, 2010 hi all i would select the 6 records before of my value and 6 record after my value. How can i obtain this result in a single query? thanks Link to comment https://forums.phpfreaks.com/topic/208173-select-a-range-between/ Share on other sites More sharing options...
bh Posted July 19, 2010 Share Posted July 19, 2010 Sadly theres no such a thing as ROWNUM or ROWID in MySQL. Im only guessing, but ive had an idea, and this is the result. SET @num = 0; SELECT (@num:=@num+1) AS abc, id, name FROM user__group GROUP BY abc HAVING abc > 2 AND abc < 4 @num is the alternate of ROWNUM. You cannot use @num in the WHERE clause, so you need the GROUP BY clause for the HAVING... Link to comment https://forums.phpfreaks.com/topic/208173-select-a-range-between/#findComment-1088131 Share on other sites More sharing options...
fenway Posted July 21, 2010 Share Posted July 21, 2010 I don't think you understood the OP's question. Link to comment https://forums.phpfreaks.com/topic/208173-select-a-range-between/#findComment-1089311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.