PDA

View Full Version : A SQL question


Alex
11-04-2003, 07:06 AM
Hi everybody

I am trying to apply an OUTER JOIN on multiple fields.

Table1: (firstname, lastname)
Table2: (firstname, lastname)

Table2 has all firstnames which is in Table1
Table2 has all lastnames which is in Table1
But Table2 does not have all combination of (firstname, lastname) as
Table1 does. For these rows I would like to have a NULL entry in
Table2.

The following is not working

select t2.firstname, t2.lastname
from table1 t1, table2 t2
where t1.firstname = (+)t2.firstname
and t1.lastname = (+)t2.lastname

Any comment?

Jeff
11-04-2003, 07:53 AM
In article <29ff93bc.0311040706.68478886@posting.google.com>, alexsm@eudoramail.com (Alex) wrote:Hi everybodyI am trying to apply an OUTER JOIN on multiple fields.Table1: (firstname, lastname)Table2: (firstname, lastname)Table2 has all firstnames which is in Table1Table2 has all lastnames which is in Table1But Table2 does not have all combination of (firstname, lastname) asTable1 does. For these rows I would like to have a NULL entry inTable2.The following is not workingselect t2.firstname, t2.lastnamefrom table1 t1, table2 t2where t1.firstname = (+)t2.firstnameand t1.lastname = (+)t2.lastnameAny comment?

Define "not working."

The one thing that stands out to me is that the (+)'s need to follow the
column names, not precede them. Like so:

select t2.firstname, t2.lastname
from table1 t1, table2 t2
where t1.firstname = t2.firstname(+)
and t1.lastname = t2.lastname(+);


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service