Page 1 of 1

Table Join

PostPosted: Mon Jun 20, 2011 6:17 pm
by Vineet
Hi All,

I am Having 2 Table Table1 & Table2. Table1 Having Col. as A1,A2,A3,A4 & Table B Having Col. As B1,B2,B3,B4. Col. A1 From Table1 & Col. B1 From Table2 Is Common i.e. Both Col's Have Same Value. My Requirement is, I would like to Extract All Records From Table1, For Col. A1 Base on the Criteria where Record Present in Col. A1 But
Not Present in Table2 For B1. Below is Example.

Table1:
A1 A2 A3 A4
1 X X1 X2
2 Y Y1 Y2
3 Z Z1 Z2
4 Q Q1 Q2
5 W W1 W2

Table2:
B1 B2 B3 B4
1 X X1 X2
2 Y Y1 Y2
3 Z Z1 Z2
7 T T1 T2
8 K K1 W2

Expected Output:

Should Select Value 4 & 5 From Table1 of Col. A1.

Thanks
Kind Rgds

Re: Table Join

PostPosted: Mon Jun 20, 2011 6:47 pm
by GuyC
select colA1 from stmtA
except
select colB1 from stmtB
=
select colA1 from stmtA
where not exists
(select * from stmtB
where colA1 = colB1)
=
select colA1 from stmtA
where colA1 not in
(select colB1 from stmtB)