MySQL полное внутреннее соединение - PullRequest
1 голос
/ 11 мая 2011

у меня

SELECT clientReport.id 
FROM clientReport 
LEFT JOIN report02 ON (report02.id = clientReport.id)
WHERE report02.id is null;

, что эквивалентно

SELECT clientReport.id
WHERE clientReport.rowNumber NOT EXISTS (
SELECT clientReport.rowNumber FROM report02, clientReport
WHERE report02.id=clientReport.id);

Мне нужно, по-видимому, полное внутреннее объединение, чтобы получить также несоответствия в report02, а не только clientReport. Как мне написать объединение, чтобы сделать это?

1 Ответ

1 голос
/ 11 мая 2011

Ниже должно работать.

SELECT clientReport.id,report02.id
FROM clientReport 
FULL OUTER JOIN report02 ON (report02.id = clientReport.id)
WHERE report02.id is null
OR clientReport.id is null;

Должен, но не поддерживает (поскольку MySQL в настоящее время не поддерживает FULL OUTER JOIN.)

Скорее всего, сработает:

( SELECT clientReport.id  AS report01
       , report02.id      AS report02
  FROM clientReport 
  LEFT  OUTER JOIN report02
      ON (report02.id = clientReport.id)
  WHERE report02.id IS NULL
)
UNION
( SELECT clientReport.id  AS report01
       , report02.id      AS report02
  FROM clientReport 
  RIGHT OUTER JOIN report02
      ON (report02.id = clientReport.id)
  WHERE clientReport.id is null
)
...