Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run more SQL updates in one SQL command?

Tags:

sql

mysql

I have this SQL commands, which I would like to run in one command. But if I remove the semicolon from between them, then it doesn't works anymore;

UPDATE runners SET money=20000
WHERE rrank >= 3;
UPDATE runners SET money=25000
WHERE nev = 'Master';
like image 476
Iter Ator Avatar asked Dec 12 '25 15:12

Iter Ator


1 Answers

Combine the logic into a single update:

UPDATE runners
     SET money = (case when nev = 'Master' then 25000
                       else 20000
                  end)
     WHERE rrank >= 3 or nev = 'Master';
like image 124
Gordon Linoff Avatar answered Dec 14 '25 05:12

Gordon Linoff