select *
from a t
where exists (select 1
from a
where t.b=2
or t.b = 3)
这个语句啥意思呀?
里面的查询查出来的都是1,外面的怎么可能有符合的呢?
from a t
where exists (select 1
from a
where t.b=2
or t.b = 3)
这个语句啥意思呀?
里面的查询查出来的都是1,外面的怎么可能有符合的呢?
Description of the illustration exists_condition.gif
Table 7-11 shows the EXISTS condition.Table 7-11 EXISTS Condition Type of Condition Operation Example
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);
也就是说只要内层返回至少一行,exists就成立,为true
排版乱了点,将就看吧
SQL> SELECT 1 FROM dual WHERE EXISTS (SELECT NULL FROM dual);
1
----------
1
SQL>