MySQL 在匹配和不匹配时更新 table

MySQL update table on both match and no match

我有一个 table 的统计数据,如果行符合特定条件,我想设置一个列标志。如果条件不匹配,我还想清除列标志。我想出了第一部分,但我不确定如何清除标志。

UPDATE my_table
JOIN
(
    SELECT id
    FROM my_table
    WHERE criteria > "5"
) a
ON my_table.id=a.id
SET flag="1";

基本上,我想添加类似 ELSE flag="0" 的内容。

UPDATE my_table
SET flag=IF(criteria > "5", "1", "0")
;