Click to See Complete Forum and Search --> : Urgent , Please help me


ligang
05-31-2001, 01:46 AM
T1 : PK is A,B,C ;
T2 : PK is A,B,D;

Data is looks like this

T1: A , B , C1 T2: A , B , D1
A , B , C2 A , B , D2
A , B , C3

(For Same A , B combination , The records number in T1 is always large than in T2 )

I want to write a sql to show such result:

A , B , C1 , D1 ,
A , B , C2 , D2 ,
A , B , C3 , blank


How do I do ? ( the question is urgent , Please help me )

rotem_fo
05-31-2001, 05:16 AM
Hi,
Try this:

select t1.a,t1.b,c,d
from t1,t2
union
select t1.a,t1.b,c,d
from t1,t2
group by t1.a,t1.b,c,d
order by a,b,c;

good luck.