the table
id string
------------
1 aaa
2 bbb
3 ccc
4 ddd
the query
(SELECT string FROM table WHERE id > 1 ORDER BY id ASC LIMIT 1) /* num_row = 1 */
UNION
(SELECT string FROM table WHERE id < 1 ORDER BY id DESC LIMIT 1) /* null */
UNION
(SELECT string FROM table WHERE id > 4 ORDER BY id ASC LIMIT 1) /* null */
UNION
(SELECT string FROM table WHERE id < 4 ORDER BY id DESC LIMIT 1) /* num_row = 2 */
The query above will return 2 rows since there are no id=5 and id=0.
How can I tell which queries are these 2 rows fetched from?
that is, num_row = 1 from 1st SELECT, and num_row = 2 from 4th SELECT
use a second column to indicate from where the data comes from