我认为这是一个非常简单的问题,但我找不到任何有用的东西。
我做了3个选择,如下所示:
SELECT count(*) as nbTable1
FROM table1, joinTable
WHERE table1.A = joinTable.A;
SELECT count(*) as nbTable2
FROM table2, joinTable
WHERE table1.A = joinTable.A;
SELECT count(*) as nbTable3
FROM table3, joinTable
WHERE table1.A = joinTable.A;
我想将结果分成一行:
nbTable1 | nbTable2 | nbTable3 |
--------------------------------
12 | 8 | 15 |
我尝试UNION
结果,但我得到了
nbTable1 |
----------
12 |
8 |
15 |
由于我在每个请求中使用的select
,我无法在单个joinTable
中创建它...你可以帮帮我吗? :)
答案 0 :(得分:0)
SELECT
(SELECT count(*)
FROM table1, joinTable
WHERE table1.A = joinTable.A) nbTable1,
(SELECT count(*)
FROM table2, joinTable
WHERE table2.A = joinTable.A) nbTable2,
(SELECT count(*)
FROM table3, joinTable
WHERE table3.A = joinTable.A) nbTable3
FROM DUAL;