删除mysql表中不喜欢的行



我有一个包含测试结果的表。
它看起来像:

Test    | Result
Math    | Pass
Science | Fail
History | cancelled
French  | Absent

表命名为table1。我想删除表中列结果的值不是"Pass""fail"

的行

类似:

Delete from table1
where result not in (Pass, Fail);
结果表如下所示:

Test    | Result
Math    | Pass
Science | Fail

试试这个:

DELETE FROM table1 WHERE result NOT IN ('Pass', 'Fail');

您的示例通过在PassFail周围添加引号为我工作。

delete from table1
where result not in ('Pass', 'Fail')

最新更新