How to delete all rows which contains a specific value or character in a mysql database table

On my last posts I had crawled a lot of domain name on a mysql table. And now there is a new problem with specific characters like “:” and port numbers.

For example:

alfa.com:344
beta.com:245
teta.com:564
etc.

Now I want to delete all this domain names which contains the port numbers in field “url”.

MySQL command for find and delete the rows with sql-query.

DELETE FROM urls where url LIKE '%:%';

result:

mysql> DELETE FROM urls where url like '%:%';
Query OK, 1493450 rows affected (2 min 37,65 sec)

other methods:

https://stackoverflow.com/questions/4249079/mysql-delete-all-rows-containing-string-foo-in-table-bar

Leave a Comment