日期:2014-05-18 浏览次数:20469 次
declare @t table(a nvarchar(20),b nvarchar(20)) insert into @t values('a','a') insert into @t values('a','b') insert into @t values('a','c') insert into @t values('d','d') insert into @t values('a','e') SELECT * FROM @t WHERE a<>'a' AND b<>'a' /* a b -------------------- -------------------- d d */ SELECT * FROM @t WHERE a+b<>'aa' /* a b -------------------- -------------------- a b a c d d a e */
------解决方案--------------------
declare @t table(a nvarchar(20),b nvarchar(20)) insert into @t values('a','a') insert into @t values('a','b') insert into @t values('a','c') insert into @t values('d','d') insert into @t values('a','e') select * from @t where a <> 'a' or b <> 'a' /* a b -------------------- -------------------- a b a c d d a e (所影响的行数为 4 行) */