简体   繁体   English

从mysql表中删除行,其中值不喜欢

[英]Delete row from mysql table where value not like

I have a table that has the results of tests. 我有一张包含测试结果的表。
It looks like: 看起来像:

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

The table is named table1. 该表名为table1。 I want to delete rows in the table where the value of the column result is not "Pass" or "fail" 我想删除表中列结果的值不是"Pass""fail"

Something like: 就像是:

Delete from table1
where result not in (Pass, Fail);

The resulting table would look like: 结果表如下所示:

Test    | Result
Math    | Pass
Science | Fail

尝试这个:

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

Your example worked for me by adding quotes around Pass and Fail . 您的示例通过在PassFail周围添加引号来为我工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM