当前位置: 代码迷 >> Sql Server >> =======>>>问一SQL语句<<=============,该怎么解决
  详细解决方案

=======>>>问一SQL语句<<=============,该怎么解决

热度:56   发布时间:2016-04-27 17:03:53.0
=======>>>急问一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
  相关解决方案