I have table called \"users\" and need to select 2 rows before and after specific row, sorted by users.score ASC
users table (structure):
id name
(SELECT x.* FROM users x JOIN users y ON y.score <= x. score WHERE y.id = 5 ORDER BY score LIMIT 3) UNION (SELECT x.* FROM users x JOIN users y ON y.score >= x. score WHERE y.id = 5 ORDER BY score DESc LIMIT 3) [ORDER BY score] ;
http://www.sqlfiddle.com/#!9/45c22/42