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 Quote 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... Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/208173-select-a-range-between/#findComment-1089311 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.