使用 SQLite 进行完全外部联接

2021-12-08 00:00:00 join sql sqlite full-outer-join

SQLite 只有 INNER 和 LEFT JOIN.

SQLite only has INNER and LEFT JOIN.

有没有办法对 SQLite 进行完全外部联接?

Is there a way to do a FULL OUTER JOIN with SQLite?

推荐答案

是的,请参阅 维基百科.

SELECT employee.*, department.*
FROM   employee 
       LEFT JOIN department 
          ON employee.DepartmentID = department.DepartmentID
UNION ALL
SELECT employee.*, department.*
FROM   department
       LEFT JOIN employee
          ON employee.DepartmentID = department.DepartmentID
WHERE  employee.DepartmentID IS NULL

相关文章