I would like to know whether I could perform a full outer join between two tables on a full column list first, and if this fails, a partial column list.
For example:
Table A
| a | b | c |
+-----+-----+-----+
| x | y | z |
| q | r | s |
Table B
| a | b | c | d | e |
+-----+-----+-----+-----+-----+
| q | r | s | t | u |
| q | r | | x | y |
| | | | x | y |
Failed query:
SELECT *
FROM A FULL OUTER JOIN B
ON
(A.a = B.a AND A.b = B.b AND A.c = B.c)
OR (A.a = B.a AND A.b = B.b)
Desired result
| a | b | c | d | e |
+-----+-----+-----+-----+-----+
| x | y | z | | |
| q | r | s | t | u |
| q | r | | x | y |
| | | | x | y |
I am using Postgresql. Thanks for your assistance.
This query would produce the desired result exactly:
But I am not entirely convinced that your example fits your description – which leaves room for interpretation.