我有多个表,让我们称之为Bs,我首先加入他们每个人 另一个名为A的表,然后将它们的结果合并在一起。
以下是旧版SQL解决方案。此示例中的B表数为2.
SELECT
A.ID,
A.start AS start,
A.END AS END,
CONCAT("B1: ",B1.Info ),
CONCAT("B2: ",B2.Info )
FROM (
SELECT
A.ID,
A.start,
A.END,
B1.Info
FROM (
SELECT
*
FROM A
JOIN
B1
ON
(B1.ID = A.ID)
AND (B1.start = A.start)
AND (B1.END = A.END)
WHERE
(...)
GROUP BY
A.ID,
A.start,
A.END,
B1.Info),
(
SELECT
A.ID,
A.start,
A.END,
CONCAT(B2.Infor_I, "/",B2.Info_J) AS B2.Info
FROM (
SELECT
*
FROM A
JOIN
B2
ON
(B2.ID = A.ID)
AND (B2.start = A.start)
AND (B2.END = A.END)
WHERE
(...)
GROUP BY
A.ID,
A.start,
A.END,
B2.Info)
我假设遗留SQL将首先并行运行子查询(A-B1),(A-B2),...(A-Bn),然后将它们合并在一起。使用SQL标准解决这个问题的有效方法是什么?
谢谢!