读书人

exists附近有错?解决办法

发布时间: 2012-01-16 23:36:51 作者: rapoo

exists附近有错?
select top 16 * from picUploadT where picType= 'baobaoXiu ' and userid in (1,2,3) order by picId desc 这样是不要运行的

select top 16 * from picUploadT where picType= 'baobaoXiu ' and userid exists (1,2,3) order by picId desc 就提示错误。
请问:错在哪里?谢谢

[解决办法]
declare @t table(id int)
insert into @t select 1 union select 2 union select 3 union select 4

select *
from @t
where id =any (select 1 union select 2)
/*

id
-----------
1
2

*/

嘿嘿
[解决办法]
select top 16 * from picUploadT where picType= 'baobaoXiu ' and userid exists (1,2,3) order by picId desc


userid exists (1,2,3) 这里不对
exists 和 in不是一个概念

读书人网 >SQL Server

热点推荐