select a,b,c from(SELECT max(modifiedtime) a FROM tabl1 ),
(SELECT max(modifiedtime) b FROM tabl2 ),
(SELECT max(modifiedtime) c FROM tabl3 ) ;
工作正常,但......输出就像.. 行
a b c
1 1421906942814 null null
2 null 1421906942814 null
3 null null 1421906942817
但我想打印像
这样的数据 a b c
1421906942814 1421906942814 1421906942817
怎么做......
答案 0 :(得分:1)
据我所知,你需要使用一个虚拟键(即使它是一个常量)才能在它上面进行JOIN。
这有效:
SELECT t1.value,
t2.value,
t3.value
FROM
(SELECT 1 AS dummykey,
'max1' AS value) t1
JOIN
(SELECT 1 AS dummykey,
'max2' AS value) t2 ON t1.dummykey=t2.dummykey
JOIN
(SELECT 1 AS dummykey,
'max3' AS value) t3 ON t1.dummykey=t3.dummykey
答案 1 :(得分:0)
试
SELECT
(SELECT max(modifiedtime)
FROM tabl1) a,
(SELECT max(modifiedtime)
FROM tabl2) b,
(SELECT max(modifiedtime)
FROM tabl3) c;
答案 2 :(得分:0)
我会在他们之间做CROSS JOIN:
SELECT * FROM
(SELECT max(modifiedtime) FROM tabl1) a
CROSS JOIN
(SELECT max(modifiedtime) FROM tabl2) b
CROSS JOIN
(SELECT max(modifiedtime) FROM tabl3) c;