MySQL double table Join double table
Is there a way to enter fields from a dummy DUAL table in MySQL?
Let's say I have
SELECT 1 as n1 FROM DUAL
n1
--
1
and a
SELECT 2 as n2 FROM DUAL
n2
--
2
Can I join both choices by going into some kind of query like ...
SELECT 1 as n1 FROM DUAL JOIN (SELECT 2 as n2 FROM DUAL) ON 1=1
?
+3
source to share
1 answer
Here's one way ...
Select t1.n1, t2.n2
from (select 1 as n1) t1
CROSS JOIN (Select 2 as n2) t2;
Here is another
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;
and you could just do
Select 1 as n1, 2 as n2
but I am guessing there is a reason why you need connections.
+5
source to share