|
|
Joins To Rows That Don't Exist
I want to join two tables together, but if the secondary table doesn't have a row that matches, I want the primary table's row to still be returned, with the values for the secondary row being their default values. How do I accomplish that?
For example:
if I have two tables:
t1: defaults:(a=0,b=0)
+---+---+
| a | b |
+---+---+
| 1 | 3 |
| 2 | 4 |
+---+---+
t2: defaults:(a=0,c=0)
+---+---+
| a | c |
+---+---+
| 1 | 7 |
| 3 | 8 |
+---+---+
I want to execute a query like:
SELECT t1.a,t1.b,t2.c FROM t1 JOIN t2 USING(a)
But I want the result set to be
+---+---+---+
| a | b | c |
+---+---+---+
| 1 | 3 | 7 |
| 2 | 4 | 0 |
+---+---+---+
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
|
|
|