반응형
FULL OUTER JOIN with SQLite
SQLite only has INNER and LEFT JOIN.
Is there a way to do a FULL OUTER JOIN with SQLite?
Yes, see the example 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
Following Jonathan Leffler's comment, here's an alternative answer to that of Mark Byers':
SELECT * FROM table_name_1 LEFT OUTER JOIN table_name_2 ON id_1 = id_2
UNION
SELECT * FROM table_name_2 LEFT OUTER JOIN table_name_1 ON id_1 = id_2
See here for original source and further SQLite examples.
ReferenceURL : https://stackoverflow.com/questions/1923259/full-outer-join-with-sqlite
반응형
'Program Club' 카테고리의 다른 글
| TypeError: 'zip' object is not subscriptable (0) | 2020.12.25 |
|---|---|
| What does deployment target mean? (0) | 2020.12.25 |
| What is the correct way to unset a linux environment variable in python? (0) | 2020.12.25 |
| python class that acts as mapping for **unpacking (0) | 2020.12.25 |
| Why am I getting AttributeError: Object has no attribute (0) | 2020.12.25 |