首页 > 解决方案 > 从 oracle 表中过滤无效 id

问题描述

我的桌子

NAME

Peter
Lance
Oscar
Steve
Reddy

我的查询的输入是字符串数组,比方说Peter, Bond, Steve, Smith

我的查询应该返回我输入的无效值(即)Bond & Smith

我正在使用Oracle 12.1.0并且不支持 odcivarchar2list。

任何建议将不胜感激

标签: sqloracleoracle12c

解决方案


您可以使用cte

with list_string as (
     select 'Peter' as name union all
     select 'Bond' as name union all
     select 'Steve' as name union all
     select 'Smith' as name
)
select ls.name, 'Invalid Values'
from list_string  ls
where not exists (select 1 from table t1 where t1.name = t.name);

推荐阅读