只注重子查询是否有返回行,如有返回结果为真,否则为假,并不适用子查询的结果,仅用于测试子查询是否有返回结果。

语法:

if exists (子查询)
        begin
            语句块
        end
    例子:
        if exists (select *from sysdatanases where name=’e_makcd’)
        begin
            drop database e_makcd
        end
        create database e_makcd
        (             )
        go

通常使用 not exists 子查询的结果取返值

exists : 查到为真否则为假

not exists : 查到为假,否则为真

相关文章:

  • 2021-06-06
  • 2021-07-21
  • 2021-08-03
  • 2021-11-28
  • 2021-08-03
  • 2021-08-03
  • 2021-05-25
  • 2022-01-10
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案