现在遇到这样一个问题:比如 if exists a='a' then
update table set b='b' where a='a'
else
insert into t valuse(a,b)
预处理语句为
if exists a=? then
update table set b=? where a=?
else
insert into t valuse(?,?)
这里需要set 4个参数;但是实际上只有两个变量;我想问能不能用变量代替占位符;只set 2 次?
update table set b='b' where a='a'
else
insert into t valuse(a,b)
预处理语句为
if exists a=? then
update table set b=? where a=?
else
insert into t valuse(?,?)
这里需要set 4个参数;但是实际上只有两个变量;我想问能不能用变量代替占位符;只set 2 次?
你哪知道用户要输入a还是b??
比如三个字段的表;要实现主键冲突就更新否则就插入的功能;
要8个占位符;但是实际只有个不同的值,我就想设置3个变量,只用set3次
update table set b=@参数2 where a=@参数1
else
insert into t valuse(@参数1,@参数2)
放存储过程里