您好,我在数据库中有一个表格,我只想排除AccType In(' Lisa')和AccCodeValue In(' 1a',' 4克'' 1C') 归还其他一切。
所以预期的结果集是
但实际的结果集是
出了什么问题,我认为这将是一个简单的查询,如
Select * From table Where AccType In ('Lisa') And AccCodeval Not In ('1a','1c','4g')
由于
答案 0 :(得分:2)
试一试:
SELECT *
FROM [yourtable] AS a
WHERE
NOT EXISTS
(SELECT *
FROM [yourtable] AS b
WHERE
a.accid = b.accid
AND
a.acctype = 'lisa'
AND
a.accCodeValue IN('1a', '4g', '1c'))
答案 1 :(得分:0)
我不完全确定你问的是什么,但我认为你正在寻找的东西是这样的:
select * from [yourTable]
where AccType <> 'Lisa'
and AccCodeValue not in ('1a', '4g', '1c')
答案 2 :(得分:0)
SELECT *
FROM #Acc
WHERE AccType <> 'Lisa' AND AccCode NOT IN ('1a','4g','1c')