请教高手,急急急!!!在线等

mycenter1117 2003-10-17 10:59:29
有三张表table1、table2、table3,如果table1.ID=0那么table1需要join table2,否则table1需要join table3,下面的语句总是提示"在关键字 'case' 附近有语法错误。"不知道为什么?请高手指教,在线等!!

select *
from table1
(case
when table1.ID=0 then ( join table2 on ...)
else ( join table3 on ...)
end)
...全文
29 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
伍子V5 2003-10-17
  • 打赏
  • 举报
回复
你这条路是走不通的
不是有高手给你解答了么,难道不行?
yujohny 2003-10-17
  • 打赏
  • 举报
回复
case不能这样用,必须改为:
select *
from table1 inner join table2 on ……
where table1.ID=0
union all
select *
from table1 inner join table3 on ……
where table1.ID<>0

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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