表A:
a
1
2
3
4
5
6
7
8
表B:
a b
1 11
2 12
3 13
5 15
7 17
8 18
表C:
b c
11 20
12 50
15 80
18 75
我需要得到的查询结果为:
a c
1 20
2 50
3
4
5 80
6
7
8 18
也就是我要查所有在表A中字段a的值通过表B的字段b关联到表C中的对应字段c的值!请高手指点!谢谢!
10 个解决方案
#1
SELECT A.a, C.c
FROM A, B, C
WHERE A.a = B.a AND B.b = C.b;
#2
SELECT A.a, C.c
FROM A inner join B
on A.a =B.a
left join C on B.b = C.b;
#3
select ab.a,f.c from
(select a,e.b from a d left join b e using(a)) ab,c f
where ab.b=f.b(+)
order by ab.a;
#4
这个不符合要求,我自己就这样写的!
#5
也不对啊!
#6
看了半天没看明白!
#7
应该改成:
SELECT A.a, C.c
FROM A left join B
on A.a =B.a
left join C on B.b = C.b;
#8
其实就是用了两次 左外连接查询阿
#9
这下对了
谢谢!马上结贴!
#10
左连接语句,sql基础啊,建议多看看书
#1
SELECT A.a, C.c
FROM A, B, C
WHERE A.a = B.a AND B.b = C.b;
#2
SELECT A.a, C.c
FROM A inner join B
on A.a =B.a
left join C on B.b = C.b;
#3
select ab.a,f.c from
(select a,e.b from a d left join b e using(a)) ab,c f
where ab.b=f.b(+)
order by ab.a;
#4
这个不符合要求,我自己就这样写的!
#5
也不对啊!
#6
看了半天没看明白!
#7
应该改成:
SELECT A.a, C.c
FROM A left join B
on A.a =B.a
left join C on B.b = C.b;
#8
其实就是用了两次 左外连接查询阿
#9
这下对了
谢谢!马上结贴!
#10
左连接语句,sql基础啊,建议多看看书