我想检查users
表中是否存在id为10的记录。
我试图在SQL中使用exist
关键字,但我无法弄清楚使用exist
检查记录是否存在的正确语法。
我想要下面的内容
If ( exist (select id * from table where Id = id ) )
{
}
答案 0 :(得分:23)
使用Exist
关键字非常简单,
我在下面写了正确的语法,检查出来
if exists (select * from [dbo].[table] where id= [the id you want to check] )
select 'True'
else
select 'False'
return