I want to join two (or more) tables based on the set of columns that are present in all the tables involved in the join. In other words, I want to join tables based on a set of column intersections. However, each table has additional columns that are unique to this table.

Example
#: number
-: NULL
Table a
+------+------+------+ | Col1 | Col2 | ColA | +------+------+------+ | A | A | # | | A | B | # | +------+------+------+
Table B
+------+------+------+ | Col1 | Col2 | ColB | +------+------+------+ | A | A | # | | B | B | # | +------+------+------+
Result
+------+------+------+------+ | Col1 | Col2 | ColA | ColB | +------+------+------+------+ | A | A |
I came up with a solution, but the performance is terrible, performance is the problem. I do not want to pollute you with this decision. I would rather have a fresh look :)
Looking forward to your decisions. Thank you for your time. It is very much appreciated.
UPDATE
Thanks for all the answers. However, it seems that I have not sufficiently explained the problem. (I have not checked all the answers yet)
But note that in table B there is a row that is not in table A.
Table B +------+------+------+ | Col1 | Col2 | ColB | +------+------+------+ | B | B | # | +------+------+------+
And table A is the opposite.
The solution I developed joins all the tables together in a set of columns to create a skeleton.
Skeleton: SELECT Col1, Col2 FROM TableA UNION SELECT Col1, Col2 FROM TableB
As soon as I have a skeleton I LEFT OUTER JOIN for each table.
LEFT OUTER JOIN TableA AS a ON a.Col1=skeleton.Col1 AND a.Col2=skeleton.Col2 LEFT OUTER JOIN TableB AS b ON b.Col1=skeleton.Col1 AND b.Col2=skeleton.Col2
So the final request looks like this:
SELECT s.*, a.ColA, b.ColB FROM ( SELECT Col1, Col2 FROM TableA UNION SELECT Col1, Col2 FROM TableB ) s LEFT OUTER JOIN TableA a ON a.Col1=s.Col1 AND a.Col2=s.Col2 LEFT OUTER JOIN TableB b ON b.Col1=s.Col1 AND b.Col2=s.Col2