title: How to increment a column value by 1 for selected rows in postgres?
body: <p>I have a postgres table which contains the columns <code>id</code>, <code>name</code>, <code>item</code> and <code>counter</code>.Now I want to increment the <code>counter</code> value by <strong>1</strong> for those rows that the user belongs to.</p>
  
  <p>I tried doing something like this but I get syntax error</p>
  
  <pre><code>UPDATE Items set counter = counter + 1 WHERE users = 'Tony';
  </code></pre>
  
  <p>This should increment the <code>counter</code> value by <strong>1</strong> for all the rows that the user <strong>Tony</strong> belongs to.Something like </p>
  
  <p><strong>initial</strong></p>
  
  <pre><code>id | name | item    | counter
  1  | Tony  | car    | 1
  2  | Tony  | bike   | 1
  3  | Ray   | car    | 1
  4  | Ray   | bike   | 1
  5  | Tony  | cycle  | 1
  </code></pre>
  
  <p><strong>final</strong></p>
  
  <pre><code>id | name | item    | counter
  1  | Tony  | car    | 2
  2  | Tony  | bike   | 2
  3  | Ray   | car    | 1
  4  | Ray   | bike   | 1
  5  | Tony  | cycle  | 2
  </code></pre>
  
  <p>But I get syntax error for my query.What am I doing wrong?  </p>