我想要做类似如下(在SQL Server):我可以使用更新来增加SQL记录中的值吗?
update person set numItems += @num, today = @updateDate where id = @id
我知道了“一个numItems + = @num”是不正确的语法,我怎么写的那一部分?
我想要做类似如下(在SQL Server):我可以使用更新来增加SQL记录中的值吗?
update person set numItems += @num, today = @updateDate where id = @id
我知道了“一个numItems + = @num”是不正确的语法,我怎么写的那一部分?
SQL Server不具有+=
符号,所以才展开全面
update person set numItems = numItems + @num, today = @updateDate where id = @id
某些数据库做支撑+=
。但是,下面是标准的SQL:
update person
set numItems = numItems + @num,
today = @updateDate
where id = @id;
“*有些数据库支持+ = *” - 真的吗?哪一个? – 2014-09-19 21:36:06
@a_horse_with_no_name SQL Server 2008+ – 2014-09-19 22:12:42
由于SQL Server 2008中,*添加的Equals *运营商和亲属已经由SQL Server 2008的支持:http://msdn.microsoft.com/en-us/library /cc627392(v=sql.100).aspx – 2014-09-19 21:55:51