要从多个 select 语句中获取结果,请使用 UNION ALL。以下是语法 -
select yourValue1 AS anyColumnName UNION ALL select yourValue2 AS yourColumnName . . . . N
让我们实现上述语法,以返回不同行中的数字枚举 -
mysql> select 100 AS Number UNION ALL select 1000 AS Number UNION ALL select 10000 AS Number UNION ALL select 100000 AS Number UNION ALL select 1000000 AS Number UNION ALL select 10000000 AS Number UNION ALL select 100000000 AS Number UNION ALL select 1000000000 AS Number;
这将产生以下输出 -
+------------+ | Number | +------------+ | 100 | | 1000 | | 10000 | | 100000 | | 1000000 | | 10000000 | | 100000000 | | 1000000000 | +------------+ 8 rows in set (0.00 sec)
以上是MySQL查询从多个select语句中获取结果?的详细内容。更多信息请关注PHP中文网其他相关文章!