a6266318 发表于 2018-9-12 11:36:40

oracle中exists用法

比如   a,b 关联列为 a.id = b.id,现在要取 a 中的数据,其中id在b中也存在:  select * from a where exists(select 1 from b where a.id = b.id)
  或者:
  现在要取 a 中的数据,其中id在b中   不存在:
  select * from a where not exists(select 1 from b where a.id = b.id)
  例如:表B:

  表C:

  select * from B where not exists (select 1 from C where B.ID=C.ID)
  结果:

  select * from B whereexists (select 1 from C where B.ID=C.ID)
  结果:



页: [1]
查看完整版本: oracle中exists用法