-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
SELECT f1 FROM t1;

(SELECT * FROM (SELECT f1,f1 AS x FROM t1 UNION ALL SELECT f1,f1-100 AS x FROM t1) tmp1 WHERE x < 4 ORDER BY x DESC LIMIT 2)
UNION ALL
(SELECT * FROM (SELECT f1,f1 AS x FROM t1 UNION ALL SELECT f1,f1+100 AS x FROM t1) tmp2 WHERE x >= 4 ORDER BY x LIMIT 3)
ORDER BY x;
