1
Friends, I need help.
I have these two darlings:
UPDATE leilaov
SET seconds = CASE
WHEN (mesini = MONTH(NOW()) AND diaini = DAYOFMONTH(NOW()) AND horaini = HOUR(NOW()) AND minutoini <= MINUTE(NOW()))
OR (mesini = MONTH(NOW()) AND diaini < DAYOFMONTH(NOW()))
OR (mesini = MONTH(NOW()) AND diaini = DAYOFMONTH(NOW()) AND horaini < HOUR(NOW()))
OR (mesini < MONTH(NOW())) THEN seconds-1
END
WHERE numero12345 = 1
UPDATE leilaov
SET seconds = IF((mesini = MONTH(NOW()) AND diaini = DAYOFMONTH(NOW()) AND horaini = HOUR(NOW()) AND minutoini <= MINUTE(NOW()))
OR (mesini = MONTH(NOW()) AND diaini < DAYOFMONTH(NOW()))
OR (mesini = MONTH(NOW()) AND diaini = DAYOFMONTH(NOW()) AND horaini < HOUR(NOW()))
OR (mesini < MONTH(NOW())), seconds-1, seconds)
WHERE numero12345 = 1
Both work perfectly and there are no significant differences in runtime. The problem is that I need to update multiple fields and not just one.
What is the syntax for updating multiple fields? I will have to repeat the condition for each field?
Should I use CASE or IF? Or is there a better option?
Thank you in advance.
By multiple fields you mean multiple records with the
numero12345
different?– Luis Henrique
No @Luis Henrique. In the example above I am updating the Seconds field. I need to update other fields (eg mesini and diaini) from the same record. Thank you
– Manuel Martins