2012-01-25 80 views
1

MySQL版本:5.1.36在MySQL中支持嵌套聯合?

(select 
    1 as num) 
union 
(
    (select 
     2 as num) 
    union 
    (select 
     3 as num)) 

上面的查詢會引發語法錯誤。

MySQL不支持嵌套工會? MySQL文檔。對此沉默。

回答

3

我承認,我從來沒有試過要嵌套UNION,可能是因爲以下查詢等效,是可以接受的:

(SELECT 
    1 AS num) 
UNION 
(SELECT 
    2 AS num) 
UNION 
(SELECT 
    3 AS num)