如何解决从值列表中选择
所以很简单:
Select Val from MyTable where Val not in ('100','200','300'....)
-
如何编写查询,以便从列表中选择值。例如,我该如何做类似
Select * from ('100','300'....)
的事情,以使输出为:100 200 300 ...
-
此外,我该如何做类似
select * from ('100','300'....) that are not in MyTable.Val
列的事情?
解决方法
如何处理MyTable.Val中不在('100','200','300'....)中的select *。
您可以使用values()
来构建包含值列表的派生表,然后使用not exists
来过滤表中找不到的值:
select v.*
from (values (100),(200),(300)) v(val)
where not exists (select 1 from mytable t where t.val = v.val)
,
第1部分
Select * from (values ('100'),('200'),('300')) v(val);
第2部分
Select *
from
(values ('100'),('300')) v(val)
where not exists (select 1 from myTable t where t.val=v.val);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。