首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

初学者求救

2012-03-12 
菜鸟求救我有三各表a,b,c我想从三个表中去数据select*froma,b,cwherea.idb.idandc.idb.idandb.id 0001

菜鸟求救
我有三各表   a,b,c  
我想从三个表中去数据
select   *   from   a,b,c   where   a.id=b.id   and   c.id=b.id   and   b.id= '0001 '
可是   c   表中可能有时候没有这条数据     我该怎么才能准确的把数据都能准确的取出来       把and   换成or     也是查不出来


[解决办法]
--try

select * from a
left join b on a.id=b.id
left join c on b.id=c.id
where b.id= '0001 '
[解决办法]
select *
from a join b on a.id=b.id
left join c on b.id=c.id
where b.id= '0001 '

[解决办法]
我有三各表 a,b,c
我想从三个表中去数据
select * from a,b,c where a.id=b.id and c.id=b.id and b.id= '0001 '
可是 c 表中可能有时候没有这条数据 我该怎么才能准确的把数据都能准确的取出来 把and 换成or 也是查不出来

select a.*,b.*,c.* from a
left join b on a.id = b.id and b.id = '0001 '
left join c on b.id = c.id

热点排行