读书人

初学者求救

发布时间: 2012-03-12 12:45:33 作者: rapoo

菜鸟求救
我有三各表 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

读书人网 >SQL Server

热点推荐