Subject | Re: [firebird-support] SQL Select Joins Syntax |
---|---|
Author | Daniel Berstein |
Post date | 2004-03-20T02:52:31Z |
Kevin, try this:
SELECT t2.*
FROM table2 t2 LEFT OUTER JOIN table1 t1
ON t1.id = t2.id
WHERE t1.id IS NULL;
According to your goal (find out what is in table2 that is not in
table1), your join should "pivot" from table2. Using an outer join,
Firebird will fill NULL columns from table1 that do not match the join
criteria, thus we add WHERE t1.id IS NULL to the query.
BTW, I wrote this from the top of my head, and it's totally untested.
Hope it works :)
Regards,
Daniel Berstein.
El Viernes, 19 de Marzo de 2004 escribiste:
KS> Greetings,
KS> I am currently joining:
KS> select [field list]
KS> from Table1 T1
KS> left outer join Table2 T2 on T1.ID = T2.ID
KS> This gives me everything in Table1 whether or not it exists in Table2.
KS> What is the best way to find out what is in Table2 that is not in Table1.
KS> Thanks,
KS> Kevin
KS> Yahoo! Groups Links
--
Saludos,
Daniel Berstein
dbz@...
SELECT t2.*
FROM table2 t2 LEFT OUTER JOIN table1 t1
ON t1.id = t2.id
WHERE t1.id IS NULL;
According to your goal (find out what is in table2 that is not in
table1), your join should "pivot" from table2. Using an outer join,
Firebird will fill NULL columns from table1 that do not match the join
criteria, thus we add WHERE t1.id IS NULL to the query.
BTW, I wrote this from the top of my head, and it's totally untested.
Hope it works :)
Regards,
Daniel Berstein.
El Viernes, 19 de Marzo de 2004 escribiste:
KS> Greetings,
KS> I am currently joining:
KS> select [field list]
KS> from Table1 T1
KS> left outer join Table2 T2 on T1.ID = T2.ID
KS> This gives me everything in Table1 whether or not it exists in Table2.
KS> What is the best way to find out what is in Table2 that is not in Table1.
KS> Thanks,
KS> Kevin
KS> Yahoo! Groups Links
--
Saludos,
Daniel Berstein
dbz@...