My comment database just got slammed with over 11,000 spam entries. I am trying to think of a way to delete any entry with a specific word in it. There are about 12 columns per entry and I want to search all of those columns and if there are any of the "keywords" in there then delete that row. Something like:
$sql = "DELETE FROM co开发者_开发技巧mments WHERE colum1, column2, column3 = has the substring xanaxs;"
Please help so I don't have to delete 11,000 rows.
You could concatenate all the columns together:
$sql = "DELETE FROM comments WHERE concat(column1,column2,column3) like "%xanaxs%";
From a strict SQL point of view, you would have to do it one by one, as in: DELETE FROM comments WHERE column1 LIKE '%first_string%'
However, since you're in PHP, you can loop it per column and keyword, as long as you put each in an array.
ry this:
"DELETE FROM comments WHERE CONCAT_WS(colum1,column2,column3) LIKE '%xanaxs%'"
精彩评论