请问join与case在一起应该怎样使用?

mycenter1117 2003-10-17 10:48:26
rt
...全文
152 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 2003-10-17
  • 打赏
  • 举报
回复
select *
from Urge join OweDom_Sub on Urge.lSubID=OweDom_Sub.lID and Urge.lMID=0
join OweDom on Urge.lMID=OweDom.lID where Urge.lMID<>0
join RentContract on OweDom.sCntID=RentContract.sContractID
zjcxc 2003-10-17
  • 打赏
  • 举报
回复
join和case一齐,是什么意思?

--这样用可以.
select * from A where a=case when exists(select 1 from a join b on a.id=b.id) then 'abc' else '0' end
yujohny 2003-10-17
  • 打赏
  • 举报
回复
你的那样用法肯定不行,只能换种方法

select * from Urge A join OweDom_Sub B on A.lSubID=B.lID
join RentContract C on B.sCntID=C.sContractID where A.lMID=0
union all
select *
from Urge D join OweDom E on D.lMID=E.lID join RentContract F on E.sCntID=F.sContractID
where D.lMID<>0

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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