What's the command to achieve this: MYSQL: delete all rows where "row_name" column does not contain string "foo" or "bar"
Use the LIKE
operator here:
DELETE
FROM yourTable
WHERE row_name NOT LIKE '%foo%' AND row_name NOT LIKE '%bar%';
Using REGEXP
we can write this a bit more concisely:
DELETE
FROM yourTable
WHERE row_name NOT REGEXP 'foo|bar';