SQL 判断记录是否存在的几种方法

1、

if exists (select * from table1 where conditions)
    select '1'
else
    select '0' 

2、

select isnull((select top 1 * from table1 where conditions), 0)

3、

if  (select COUNT(*) from table1 where conditions) > 0
  print '1'
else
  print '0'

  

 

创建时间:2020.10.09  更新时间:

 

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-12-27
  • 2021-08-08
  • 2021-12-09
  • 2022-12-23
  • 2021-12-21
猜你喜欢
  • 2021-12-22
  • 2021-09-17
  • 2022-12-23
  • 2021-11-13
  • 2022-02-02
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案