I can’t seem to find this anywhere, but I’m trying to update multiple rows based off of one query. I want the IF parameter to execute to set all the characters to inactive then to run the query to set one character to active in order to make it so only one character can be selected.
IE
UPDATE characters SET active='1'
WHERE name = '_POST[char_name]';
But I can’t find out how to set it to where something along the lines of
IF active='1'
{
UPDATE characters SET active='0'
WHERE id= '" . $id . "';
}
The query below will set
activeto 1 if_nameis equal to$_POST['char_name']and will setactiveto 0 for other rows.For more details, see IF() MySQL function.