如何删除不包含某些数据的列的MYSQL中的行 [英] How to delete rows in MYSQL where a column doesn't contain certain data

查看:71
本文介绍了如何删除不包含某些数据的列的MYSQL中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我负责修复的数据库充满了垃圾邮件.数据库中有一个名为 url 的表.有一个名为 alias 的列.应该有 2,000条正确的别名行,而另外的 100,000+条是垃圾邮件.我有一个逗号分隔的列表,其中应该包含所有正确的值.Alias中的一个示例值将是z6j6h,并且它们都是5个字母/数字.如何删除列表中不包含值的每一行?

A database I am in charge of fixing got filled with spam. There is a table called url in the database. There is a column called alias. There is 2,000 correct alias rows that should be there and the other 100,000+ are spam. I have a comma separated list of all the correct values that should be there. An example value in Alias would be z6j6h and they are all 5 letters/numbers. How can I delete every row that does not contain a value in the good list?

推荐答案

DELETE
  FROM (table)
 WHERE alias NOT IN ('ASDFG', 'ABCDE')

这篇关于如何删除不包含某些数据的列的MYSQL中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆