要從多個 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語句中獲取結果?的詳細內容,更多請關注www.92cms.cn其它相關文章!