sqlsqlitejoinfull-outer-join

How to do a FULL OUTER JOIN in SQLite?


SQLite only supports INNER JOIN and LEFT JOIN. How do I do a FULL OUTER JOIN?


Solution

  • Yes. See the Join (SQL) > Outer join > Full outer join article on Wikipedia.

    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