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

=======>>>急问一SQL语句<<=============
有a,b,c三个表,字段分别为
a:shopid,shopname,telephone
b:menuid,dish,price
c:rangeid,shopid,buildingid

现在要求,当buildingid=1的时候列出shopname,telephone,dish,price四个字段


谢谢

------解决方案--------------------
B表跟其他表好象没有关联...
------解决方案--------------------
三張表的關聯如何?
------解决方案--------------------
select a.shopname,a.telephone,b.dish,b.price
from a,b,c
where a.shopid = b.menuid and a.shopid = c.rangeid and c.buildingid=1

这样可以么?
------解决方案--------------------
dish,price

不知道怎么列 FK是什么?
------解决方案--------------------
跟B表少了关联
------解决方案--------------------
是啊,没有b表的关联
------解决方案--------------------
select a.shopname,a.telephone,b.dish,b.price
from a,b,c
where a.shopid = c.shopid and b.shopid = c.shopid and c.buildingid=1