MySQL Forums
Forum List  »  Knowledge Base

BIG OUTER JOIN
Posted by: S Lang
Date: April 17, 2008 01:11PM

Is there a way, in mySql syntax, to join 2 tables in a sort of BIG OUTER JOIN in one SQL query (no sub-quries) as a describe below :

ex: SELECT Key, data1, data2, data3, data4
FROM table1 t1 <COMMAND> JOIN table2 t2 ON t1.Key = t2.Key

TABLE 1
Key | data1 | data2
---------------------
1 | 5.00 | 10.00
2 | 6.00 | 12.00
3 | 7.00 | 14.00

TABLE 2
key | data3 | data4
---------------------
2 | aaa | 3
3 | bbb | 4
4 | ccc | 5

RESULT TABLE
key| data1 | data2 | data3 | data4
1 | 5.00 | 10.00 | NULL | NULL
2 | 6.00 | 12.00 | aaa | 3
3 | 7.00 | 14.00 | bbb | 4
4 | NULL | NULL | ccc | 5

Now i have to built up a temporary table where i put a SELECT UNION of the 2 tables keys and than i use it as the LEFT JOIN table for those tables...

Is there an other way to do it??

Thanks a lot
Sebastien

Options: ReplyQuote


Subject
Views
Written By
Posted
BIG OUTER JOIN
4187
April 17, 2008 01:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.