有没有办法从MySQL中的虚拟DUAL表中加入字段?
说我有一个
SELECT 1 as n1 FROM DUAL
n1
--
1
和
SELECT 2 as n2 FROM DUAL
n2
--
2
我是否可以在某种查询中加入两个选择作为...
SELECT 1 as n1 FROM DUAL JOIN (SELECT 2 as n2 FROM DUAL) ON 1=1
答案 0 :(得分:5)
这是一种方式......
Select t1.n1, t2.n2
from (select 1 as n1) t1
CROSS JOIN (Select 2 as n2) t2;
这是另一个
Select t1.n1, t2.n2
from (select 1 as n1, 'A' as ID) t1
INNER JOIN (Select 2 as n2, 'A' as ID) t2
on T1.Id = T2.ID;
你可以做到
Select 1 as n1, 2 as n2
但我认为你需要连接的原因。