brihol44
asked on
add +1 to column value in mySQL
How would I add +1 value to an existing column value in my table? Feel like this is a easy question but I haven't done it for a while and forgot the syntax to do so.
I tried...
UPDATE user_projects
SET views = views + 1
Didn't work.
Thx for the help!
I tried...
UPDATE user_projects
SET views = views + 1
Didn't work.
Thx for the help!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good catch... I didn't copy the complete query statement on accident...
I tried the above solution and that didn't work. Any other thoughts?
UPDATE user_projects
SET views = views + 1
WHERE project_ID = '#project_ID#'
Thx,
Brian
I tried the above solution and that didn't work. Any other thoughts?
UPDATE user_projects
SET views = views + 1
WHERE project_ID = '#project_ID#'
Thx,
Brian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My IDs are like so... B690F14E-08-08-11... So I do need the quotes. Looks like everything is working though now. I'll give everybody equal points.
Thank you!
Thank you!
Therefore you need to put [ ] brackets around the field name.
E.g
UPDATE user_projects
SET [views] = [views] + 1
Can you try this and see if it works?