MySQL:如果单元格中的字符串匹配,则删除 table 行?

MySQL: delete table rows if string in cell is matched?

我有一个包含 meta_key 列的 table …我想删除 table 中 meta_key 匹配某个字符串的所有行。

例如,我想删除其中包含 "tel" 的所有 3 行 - 只是单元格而不是整行。我怎样才能用 mysql 语句做到这一点?

DELETE FROM table WHERE meta_key = 'tel' //will delete exact match

DELETE FROM table WHERE meta_key = '%tel%'//will delete string contain tel
delete from tablename where meta_key = 'tel'

下面的查询删除了字符串包含 "tel" 的行:

   DELETE FROM my_table WHERE meta_key like '%tel%';

这是 Pattern matching 的一部分。

如果您希望 meta_key 字符串等于 "tel" 那么您可以尝试以下操作:

   DELETE FROM my_table WHERE meta_key = 'tel'

这是一个简单的Delete

DELETE FROM `table_name` WHERE meta_key = "tel";

为了将来,请尝试阅读 docs

DELETE FROM table
        WHERE meta_key= 'tel';

此外,您可以使用 limit 指定要删除的行数