You can do it in a little more convoluted way not using UNION at all:
SELECT * FROM table WHERE id=(SELECT id FROM table WHERE id>? ORDER BY id ASC LIMIT 1) OR id=(SELECT id FROM table WHERE id<? ORDER BY id DESC LIMIT 1)
Careful with that hash Eugene.
In reply to Re^4: Calculating previous/next from database
by psini
in thread Calculating previous/next from database
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |