I have a postgres table which contains the columns id, name, item and counter.Now I want to increment the counter value by 1 for those rows that the user belongs to.
I tried doing something like this but I get syntax error
UPDATE Items set counter = counter + 1 WHERE users = 'Tony';
This should increment the counter value by 1 for all the rows that the user Tony belongs to.Something like
initial
id | name | item | counter
1 | Tony | car | 1
2 | Tony | bike | 1
3 | Ray | car | 1
4 | Ray | bike | 1
5 | Tony | cycle | 1
final
id | name | item | counter
1 | Tony | car | 2
2 | Tony | bike | 2
3 | Ray | car | 1
4 | Ray | bike | 1
5 | Tony | cycle | 2
But I get syntax error for my query.What am I doing wrong?
namebut not one calleduser.