Gav*_*orn 1 sql oracle plsql plsqldeveloper
我正在尝试编写一个plsql查询,它允许我查询一组未存储在表中的已知值.假设这些已知值是以下字符串:
我想实现以下内容:
select * from [fill-in-the-blank] myvalues
where not myvalues in
(
select id from dbtable
)
..我试图确定哪些知识值不在数据库表中.
约束
有任何想法吗?
您可以使用公用表表达式(CTE)来完成此任务:
with cte as (
select 'abc' as id from dual
union all
select 'def' from dual
union all
select 'ghi' from dual
union all
select 'jkl' from dual
)
select *
from cte
where not id in
(
select id from dbtable
)
Run Code Online (Sandbox Code Playgroud)
事实上,你可能根本不需要CTE(尽管我发现它有助于提高可读性):
select *
from (
select 'abc' as id from dual
union all
select 'def' from dual
union all
select 'ghi' from dual
union all
select 'jkl' from dual
)
where not id in
(
select id from dbtable
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2014 次 |
| 最近记录: |