首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

子查询有关问题

2012-02-09 
子查询问题当执行if(@last1+@last2)%106and((selectP3fromxuewhereid@idN)in(6,7))显示消息512,级别16,

子查询问题
当执行
if   (@last1+@last2)%10=6   and   ((select   P3   from   xue   where   id=@idN)   in   (6,7))
显示

消息   512,级别   16,状态   1,第   111   行
子查询返回的值不止一个。当子查询跟随在   =、!=、 <、 <=、> 、> =   之后,或子查询用作表达式时,这种情况是不允许的。
==================

我理解是不能使用in
请教简单的修改,使其可运行和达到原来代码用途。

[解决办法]
if (@last1+@last2)%10=6 and ( exists (select 1 from xue where id=@idN and P3 in(6,7)) )

热点排行