select A,B,C,D,E,F,G,H from table2 a cross join table3 b right join table1 c on c.a=a.a and c.b=b.b
这样会不会漏掉table1的一些数据啊?
不可能吧 比如: A =1 B = 2 D =3 A =1 B = 2 D =4 这两条记录选哪条呢?
select * from (select * from t1 t where d = (select top 1 d from t1 where a=t.a and b = t.b)) a left join t2 b on a.a = b.a left join t3 c on a.b = c.b
select * from (select * from t1 t where d = (select top 1 d from t1 where a=t.a and b = t.b)) a full join t2 b on a.a = b.a full join t3 c on a.b = c.b
比如:
A =1 B = 2 D =3
A =1 B = 2 D =4
这两条记录选哪条呢?
(select * from t1 t where d = (select top 1 d from t1 where a=t.a and b = t.b)) a
left join t2 b on a.a = b.a
left join t3 c on a.b = c.b
(select * from t1 t where d = (select top 1 d from t1 where a=t.a and b = t.b)) a
full join t2 b on a.a = b.a
full join t3 c on a.b = c.b