目的:检测某条记录是否存在,比如下面的命令为检测是否有id=1972的记录存在,结果不存在,那么请问此时读取该表中字段name=rs("name")的值为什么呢?
select* from product where id=1972
if rs("id")null then
response.write("ok")
else
response.write("no")
end if
可是为什么这几句代码执行不成功呢 ?
当查询的记录存在的时候能显示ok,当记录不存在的时候也不显示no,这个是为什么呢?
select case when exists(select 1 from table where id=1972) then t.name else '' end name from table t where t.id=1972----------------------------从你的问题上看 你的id跟name字段是没有关联的------------------------但从你补充的问题上来看 你是关联的在你做if rs("id")null then response.write("ok") else response.write("no") end if 判断之前 请先判断rs存...