桌子
id string
------------
1 aaa
2 bbb
3 ccc
4 ddd
查询
(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 */
上面的查询将返回2 rows
,因为没有 id=5 和 id=0。
如何判断这 2 行是从哪些查询中提取的?
也就是说,num_row = 1
从1st SELECT
和num_row = 2
从4th SELECT