如何将一条带有自增加的update语句和insert语句合并为replace
lscxp 2013-12-05 04:40:17 当然,如果用其他编程语言在程序上实现是很容易的,只需要查两次表即可。不过我想知道能不能在同一次查询中出现
例如
insert into table (a,b,c) values (1,2,3)
和
update table set a=1,b=2 where c=3
可以合并为
replace into table a=1,b=2,c=3
那么如果我要
insert into table (a,b,c) values (1,2,3)
和
update table set a=a+1,b=b+2 where c=3
合并起来写成SQL文,应该怎么写?
replace table set a=a+1,b=b+2 where c=3 这种写法是不行的,这种写法等号右边出现字段名会自动变成这个字段的默认值而不是现在的值。