0
Add the average calculation in your update, but if your field is type integer the average will ignore the decimals, for this reason I am adding a CAST AS DECIMAL for your average field consider the decimal places.
UPDATE
SET rate_general = CAST((rate_food + rate_service + rate_price + rate_environment) AS DECIMAL(12,2)) / 4
Don’t forget to add the clause WHERE if you want to add some filter to update the records.
this way:
Update reviews set rate_general=(rate_food + rate_service + rate_price + rate_environment) / 4 where <critério>
– William John Adam Trindade
what would be the criterion ? remembering the average of each record is different
– Daywison Ferreira Leal
if you want to update all, have no criterion. just use this
query
there without thewhere
. Do the oldupdate sem where
.– Thiago Magalhães
Avoid putting images in questions, makes it difficult to answer because it is not possible to copy the code to test. A lot of people have "laziness" to analyze questions with images.
– Pedro Augusto
https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html a solution can be create this media column as calculated virtual.
– Motta