Reputation: 32874
I want to do something like the following (in Sql Server):
update person set numItems += @num, today = @updateDate where id = @id
I know the "numItems += @num" is not correct syntax, how do I write that part?
Upvotes: 0
Views: 55
Reputation: 2797
SQL Server doesn't have a +=
notation, so just expand it fully
update person set numItems = numItems + @num, today = @updateDate where id = @id
Upvotes: 2
Reputation: 1269513
Some databases do support +=
. However, the following is standard SQL:
update person
set numItems = numItems + @num,
today = @updateDate
where id = @id;
Upvotes: 1