PostgreSQL
 sql >> Datenbank >  >> RDS >> PostgreSQL

Erhöhen Sie einen Wert in Postgres

UPDATE totals 
   SET total = total + 1
WHERE name = 'bill';

Wenn Sie sicherstellen möchten, dass der aktuelle Wert tatsächlich 203 beträgt (und ihn nicht versehentlich wieder erhöht), können Sie auch eine weitere Bedingung hinzufügen:

UPDATE totals 
   SET total = total + 1
WHERE name = 'bill'
  AND total = 203;