Search MYSQL if string contains special characters?

I need to find the table field contains special characters. I found the solution given here , for example:

SELECT * FROM `tableName` WHERE `columnName` LIKE "%#%" OR `columnName` LIKE "%$%" OR (etc.) 

But this solution is too great. I need to mention all the special characters. But I want something like:

 SELECT * FROM `tableName` WHERE `columnName` LIKE '%[^a-zA-Z0-9]%' 

This is a search column that contains not only az, AZ and 0-9, but also some other characters. Is this possible with MYSQL

+5
source share
1 answer

Use regexp

 SELECT * FROM `tableName` WHERE `columnName` REGEXP '[^a-zA-Z0-9]' 

This will select all rows in which a particular column contains at least one character without alphanumeric characters.

or

 REGEXP '[^[:alnum:]]' 
+9
source

Source: https://habr.com/ru/post/1235274/


All Articles