Question

I am bit novice regarding databases and I will highly appreciate any help given. I need to decrease all cells by X in one column of a table. Do I need to select the table and the column and use the value as variable like $value=$value +/- X;

Était-ce utile?

La solution

Well then simply do so by

UPDATE yourtablename SET columnname = columname-1

(if your column/cell is of a integer type this works fine) and dont enter a WHERE CLAUSE (updating all rows)

Autres conseils

Try this,

UPDATE tableName
SET colName = colName - 5   -- this will decrease the  value by 5
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top