日期:2014-05-18  浏览次数:20657 次

三张表查询的语句怎么写,,,在线等!!!
打个比方吧·A(vc_id,vc_name) B(vc_id vc_Aid) c(vc_id vc_Bid) 我要通过C里面的Bid查询A里面的vc_name语句怎么写

------解决方案--------------------
select * from A,B,c where A.vc_id=B.vc_id and A.vc_id=B.vc_id and B.vc_id=C.vc_id 

------解决方案--------------------
select aa.vc_name from A aa,B bb,C cc where cc.vc_Bid=bb.vc_id and bb.vc_Aid=aa.vc_id 
and cc.vc_Bid=你的其它条件
------解决方案--------------------
select vc_name
from A
where vc_id in
(
select vc_id
from C
where vc_Bid = ....
)

------解决方案--------------------
select a.name from A a join B b where b.Aid = a.id join C c where c.Bid = b.id
------解决方案--------------------
select vc_name 
from A a 
where a.vc_id in 

select vc_id 
from C c
where c.vc_Bid = xxx你的条件
)
------解决方案--------------------
select a.vc_name from a where a.vc_id in
(select b.vc_aid from b,c where b.vc_id=c.vc_bid 
and c.vc_bid=?)
------解决方案--------------------
select a.vc_name from A a
join C c on c.vc_id = a.vc_id
where c.vc_Big = ""
------解决方案--------------------
呵呵,把题目写清楚点嘛,,,我试了这两个都可以;

select a.a_name from a join b on b.r_aid=a.a_id join c on c.r_bid=b.b_id where 条件
或者
select a.a_name from a where a_id in (select b.r_aid from b where b.b_id in (select c.r_bid from c where 条件))

不对的地方请指正!
------解决方案--------------------
教你一个高招,在视图设计器里做视图,很方便的
------解决方案--------------------
用关键字关联啊,或者套查询啊
------解决方案--------------------
这种写法比较清楚:
select vc_name 
from A 
where vc_id in 

select vc_id 
from C 
where vc_Bid = .... 



这种写法比较简单:
select * from A,B,c where A.vc_id=B.vc_id and A.vc_id=C.vc_id and B.vc_id=C.vc_id
------解决方案--------------------
子查询。。。