查询问题

jamzh 2003-10-10 12:09:31
查询表a中的字段col1,col2与表b中的字段col3
表a(id)与表b(name)同过表c(id,name)联系
要求能将a,b合并成一个表
如何查询
并且将为空的数据设置为0
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
txlicenhe 2003-10-10
  • 打赏
  • 举报
回复
是这样吗?
Select IsNull(a.col1,0),IsNull(a.col2,0),IsNull(b.col3,0)
from c
join a on a.id = c.id
join b on b.name = c.name
welyngj 2003-10-10
  • 打赏
  • 举报
回复
select isnull(d.col1,0)col1 ,isnull(d.col2,0) col2, isnull(b.col3,0)col3 into temp1 from b left join
(select col1,col2,c.name,c.id from a , c where a.id=c.id )as d
on b.name=d.name
然后select * from temp1
welyngj 2003-10-10
  • 打赏
  • 举报
回复
select isnull(d.col1,0)col1 ,isnull(d.col2,0) col2, isnull(b.col3,0)col3 into temp1 from b left join
(select col1,col2,c.name,c.id from a , c where a.id=c.id )as d
on b.name=d.name

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧