1
How to update several records by setting different values, example:
$update = "UPDATE tabela SET ativo=1, nivel=2 WHERE nome ='jose'
AND nome='maria'
AND nome='joao'";
then I just want Jose to receive the level=2 and the rest receive level=1 in the same query. and active=1 for all.
I’m using PHP with PDO.
Thanks, I didn’t know you could use IF inside the query. But I see no other option for my system, in this case it is a group registration of students where only the leader of the group receives level 2 at the time of registration
– Gabriel Godoy
This IF is a function, equivalent to the ternary of other languages
expressão ? valor se verdadeiro : valor se falso
- in this case, if the first parameter is true, returns the second, otherwise returns the third.– Bacco