Q:

mysql get row before and after sortindex

I have a table like this:
id    sortindex
1     15
2     3
4     1
5     4
8     6
11    2
13    5

I want get the row before and after sortindex.
For Example:
I have given the id 5 (so, sortindex 4)
The table should order by sortindex (ASC)
And now I want get the row before
should return:
id    sortindex
2     3

and the row after
should return:
id    sortindex
13    5

How I must build the Query's?
(I want two Query's: one for before and one for after)

A:

SELECT * FROM table1 WHERE sortindex < 4 ORDER BY sortindex DESC LIMIT 1
UNION ALL
SELECT * FROM table1 WHERE sortindex > 4 ORDER BY sortindex ASC LIMIT 1

