高手请帮忙,如何改这个SQL?

雄牛 2006-03-10 05:08:21
WIN98+ACCESS2000

由于Sclass 没有任何记录时,以下查询就出现"无当前记录"的错误,请问如何用IIF改,使其不为空时才执行?而且不为出错.

Select Sname from Sclass where BnameId in (select Bid from Bclass where Bname='电脑设备')

在线等..
...全文
52 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lsqkeke 2006-03-10
  • 打赏
  • 举报
回复
if exists(Select 1 from Sclass where BnameId in (select Bid from Bclass where Bname='电脑设备'))
Select Sname from Sclass where BnameId in (select Bid from Bclass where Bname='电脑设备')

22,209

社区成员

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

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