dim str
str=request.form("uname")
conn.execute "update table set user='"&str&"' where id=1"
改变字段user的内容,如果user为空的话,直接赋值,如果user不为空的话,用,隔开后添加新值,譬如:值1,值2请教带判断的这个sql语句怎么写呢?
请教。

解决方案 »

  1.   


    update table set user= 
    case when user is null  then '"&str&"' else '值1'+'值2' end 
      where id=1
      

  2.   

    这个写法为什么不对?请教。
    update PriceSpotTable set Unumber= case when Unumber is null then '123' else Unumber+','+'123' end  where SpotID=48
    如果Unumber为空,则直接赋值,如果不为空,则在原来的值的基础上加逗号,在赋值。
    显示错误:语法错误,操作符丢失。
      

  3.   

    已经解决了,是access数据库,必须用iif。谢谢各位的参与。
    update PriceSpotTable set Unumber_2= iif(Unumber_2 is null, '123' , Unumber_2+','+'123') where SpotID=48