当前位置: 代码迷 >> Sql Server >> 怎样用一句SQL语句,从三张表中取出数据,解决方法
  详细解决方案

怎样用一句SQL语句,从三张表中取出数据,解决方法

热度:84   发布时间:2016-04-27 21:44:03.0
怎样用一句SQL语句,从三张表中取出数据,
我试了半天总是取不出来。
select   a.x,b.x,c.x   from   a,b,c   on   a.x=b.x   and   a.x=c.x


------解决方案--------------------
语句没问题
------解决方案--------------------
select a.x,b.x,c.x from a,b,c where a.x=b.x and a.x=c.x

如果x同名,最好在select 中,对另外两个使用as 为字段取一个别名.
------解决方案--------------------
改where
------解决方案--------------------
我晕,看错了
如果是join的话加on,
不加join的话用where
------解决方案--------------------
select a.x,b.x,c.x
from a inner join b
on a.x=b.x
inner join c
on a.x=c.x
或者

select a.x,b.x,c.x from a,b,c where a.x=b.x and a.x=c.x
  相关解决方案