Oracle exists的用法

一、exists用法

  • 1、用法
select id, name, age from test where exists(select 1 from test2 where test.id = test2.id)
  • 2、""exists(xxx)""就表示括号里的语句能不能查出记录,它要查的记录是否存在。
    因此"select 1"这里的 "1"其实是无关紧要的,换成"*"也没问题,它只在乎括号里的数据能不能查找出来,是否存在这样的记录,如果存在,这条语句的where 条件成立。
原文地址:https://www.cnblogs.com/hziwei/p/14597064.html