从mysql表中删除值不相似的行

时间:2013-05-14 18:46:24

标签: mysql where delete-row

我有一张有测试结果的表格 它看起来像:

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

2 个答案:

答案 0 :(得分:3)

试试这个:

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

答案 1 :(得分:1)

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

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