mercredi 7 avril 2021

How to sum values on each row with condition?

So, basically, I want to update my table by summing values on each row, but I don't want to sum negative values.

Here is some simple code that I've tried:

UPDATE recipe SET total_time = preparation_time + cooking_time;

But sometimes, preparation_time or cooking_time is equal to -1 and when it happens I won't to parse them to be equal to 0. How can i do that?

Aucun commentaire:

Enregistrer un commentaire