9

我想检查users表中是否存在 id 为 10 的记录。

我试图exist在 SQL 中使用关键字,但我无法找出用于exist检查记录是否存在的正确语法。

我想要类似下面的东西

If ( exist (select id * from table where Id = id ) ) 
{

}
4

1 回答 1

23

关键字很容易使用Exist,我在下面写了正确的语法,检查一下

if exists (select * from  [dbo].[table] where id= [the id you want to check] ) 
select 'True'  
else 
select 'False' 
return
于 2013-06-22T09:18:11.470 回答