您的位置:首页 > 数据库 > Oracle

oracle exists 条件查询

2016-11-01 00:00 176 查看
select /*+index(table_a columna)*/ distinct tx_oper_id
from table_a
where not exists(
select *
from
table_b
where b.id=a.id
)

参考Oracle官方说明

https://docs.oracle.com/cd/B19306_01/server.102/b14200/conditions012.htm

EXISTS Condition

An
EXISTS
condition tests for existence of rows in a subquery.



Table 7-11 shows the
EXISTS
condition.

Table 7-11 EXISTS Condition

Type of ConditionOperationExample
EXISTS
TRUE
if a subquery returns at least one row.
SELECT department_id
FROM departments d
WHERE EXISTS
(SELECT * FROM employees e
WHERE d.department_id
= e.department_id);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息