共3个表(A表,B表,C表)
A表三个字段(A1,A2,A3)
B表三个字段(B1,B2,B3)
C表三个字段(C1,C2,C3)查询 select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3//列出满足条件A.A1,B.B1
我想要上面查询结果A.A1与C表中C.C1比较,相同的同上面一起列出来,如何写。
非常谢谢
A表三个字段(A1,A2,A3)
B表三个字段(B1,B2,B3)
C表三个字段(C1,C2,C3)查询 select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3//列出满足条件A.A1,B.B1
我想要上面查询结果A.A1与C表中C.C1比较,相同的同上面一起列出来,如何写。
非常谢谢
select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3)tp
join c on tp.a1=c.c1
select A.A1,B.B1,C.C1 from A,B,C where A.A2=B.B2 and A.A3=B.B3 AND A.A1=C.C1
这个意思?
select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3)tp
union all
select 字段,字段 from (
select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3)tp
join c on tp.a1=c.c1
--这样也可以
select A.A1,c.*
from A,B,c
where A.A2=B.B2 and A.A3=B.B3 and a.a1=c.c1
select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3
当成一个表咧?
select A.A1,B.B1 from A,B where A.A2=B.B2 and A.A3=B.B3
left join
select A.A1,C.C1 from A,C where A.A2=C.C2 and A.A3=C.C3
---
要union all
union all select A.A1,c.c1 from A,c where A.A1=c.c1