View Full Version : SQL question
Hi ALL
I've two tables and am trying to apply an OUTER JOIN on multiple fields.
Table A has some rows as:
<Table A>
--- ---
1 a
1 b
2 b
3 a
3 c
Table B is missing some of the rows.
<Table B>
--- ---
1 a
2 b
3 c
Looking for only those rows Table B is missing:
----------
1 b NULL
3 a NULL
The following is not working:
select t1.number, t1.letter, t2.number, t2.letter
from TableA t1, TableB t2
where t1.number = (+)t2.number
and t1.letter = (+)t2.letter
Hans Forbrich
11-04-2003, 02:44 PM
The OUTER JOIN topic is rather significant and there are some
limitations, such as FULL OUTER JOIN is not intuitively obvious.
Please consider reading the relevant material: http://docs.oracle.com >
doc for your version (this is definitely version dependant) and search
on 'Outer Join'.
Also, when posting such questions, please indicate the message from the
server. A blunt 'not working' could be a typo, a syntax error, or
possibly it's running to completion with results other than unexpected.
select a.col1,a.col2, null col3 from a
where not exists (select null from b where b.col1=a.col1 and b.col2=a.col2)
regards az5
"Alex" <alexsm@eudoramail.com> wrote in message
news:29ff93bc.0311041324.2a524f3b@posting.google.com... Hi ALL I've two tables and am trying to apply an OUTER JOIN on multiple fields. Table A has some rows as: <Table A> --- --- 1 a 1 b 2 b 3 a 3 c Table B is missing some of the rows. <Table B> --- --- 1 a 2 b 3 c Looking for only those rows Table B is missing: ---------- 1 b NULL 3 a NULL The following is not working: select t1.number, t1.letter, t2.number, t2.letter from TableA t1, TableB t2 where t1.number = (+)t2.number and t1.letter = (+)t2.letter
Merci
11-05-2003, 11:00 AM
select a.num, a.let, decode(b.num,null,'NULL')
from a, b
where b.num(+) = a.num
and b.let(+) = a.let
and b.num is null
"az5" <az5@telus.net> wrote in message news:KfWpb.9898$6A4.9774@edtnps84... select a.col1,a.col2, null col3 from a where not exists (select null from b where b.col1=a.col1 and
b.col2=a.col2) regards az5 "Alex" <alexsm@eudoramail.com> wrote in message news:29ff93bc.0311041324.2a524f3b@posting.google.com... Hi ALL I've two tables and am trying to apply an OUTER JOIN on multiple fields. Table A has some rows as: <Table A> --- --- 1 a 1 b 2 b 3 a 3 c Table B is missing some of the rows. <Table B> --- --- 1 a 2 b 3 c Looking for only those rows Table B is missing: ---------- 1 b NULL 3 a NULL The following is not working: select t1.number, t1.letter, t2.number, t2.letter from TableA t1, TableB t2 where t1.number = (+)t2.number and t1.letter = (+)t2.letter
Mr E Guest
11-14-2003, 02:18 AM
Why not...
SELECT num,
let
FROM a
MINUS
SELECT num,
let
FROM b;
"Merci" <msmith@whi.org> wrote in message news:<bobhc4$s1k$1@lists.fhcrc.org>... select a.num, a.let, decode(b.num,null,'NULL') from a, b where b.num(+) = a.num and b.let(+) = a.let and b.num is null "az5" <az5@telus.net> wrote in message news:KfWpb.9898$6A4.9774@edtnps84... select a.col1,a.col2, null col3 from a where not exists (select null from b where b.col1=a.col1 and b.col2=a.col2) regards az5 "Alex" <alexsm@eudoramail.com> wrote in message news:29ff93bc.0311041324.2a524f3b@posting.google.com... Hi ALL I've two tables and am trying to apply an OUTER JOIN on multiple fields. Table A has some rows as: <Table A> --- --- 1 a 1 b 2 b 3 a 3 c Table B is missing some of the rows. <Table B> --- --- 1 a 2 b 3 c Looking for only those rows Table B is missing: ---------- 1 b NULL 3 a NULL The following is not working: select t1.number, t1.letter, t2.number, t2.letter from TableA t1, TableB t2 where t1.number = (+)t2.number and t1.letter = (+)t2.letter
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
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.