2
I have the following table in a mysql database:
I would like a command to run in phpmyadmin, which sums the current value of the rating_sum column with 5, and rating_count with 1, thus leaving:
I want to add these values (5 , 1) to all rows of the table, without any restriction. I tried some things I found here in the OS, but they were examples to display the total value of a certain column, and it’s not what I need.
How could I?
SELECT *, ( rating_sum + 5 ), ( rating_count + 1 ) FROM TABELA
– MarceloBoni
@Marceloboni hello, the command you passed, only creates two new columns with the added values, but does not change the values already present in the table, I tried to adapt to UPDATE DATABASE.TABLE SET `, ( rating_sum + 5 ), ( rating_count + 1 ); but gives a syntax error.
– Wesley
A ta, I get it,
UPDATE BANCO.TABELA SET rating_sum = ( rating_sum + 5 ), rating_count = ( rating_count + 1 );
– MarceloBoni
@Marceloboni thank you very much, it worked exactly as you would like, can add as reply to mark as resolved please?
– Wesley