I need to search table field contains special characters. I found a solution given here something like:
我需要在搜索表字段中包含特殊字符。我找到了一个解决方案,例如:
SELECT *
FROM `tableName`
WHERE `columnName` LIKE "%#%"
OR `columnName` LIKE "%$%"
OR (etc.)
But this solution is too broad. I need to mention all the special characters. But I want something which search something like:
但这个解决方案太宽泛了。我需要提到所有特殊字符。但我想要一些搜索类似的东西:
SELECT *
FROM `tableName`
WHERE `columnName` LIKE '%[^a-zA-Z0-9]%'
That is search column which contains not only a-z, A-Z and 0-9 but some other characters also. Is it possible with MYSQL
这是搜索列,它不仅包含a-z,A-Z和0-9,还包含其他一些字符。是否可以使用MYSQL
1 个解决方案
#1
9
Use regexp
使用正则表达式
SELECT *
FROM `tableName`
WHERE `columnName` REGEXP '[^a-zA-Z0-9]'
This would select all the rows where the particular column contain atleast one non-alphanumeric character.
这将选择特定列包含至少一个非字母数字字符的所有行。
or
要么
REGEXP '[^[:alnum:]]'
#1
9
Use regexp
使用正则表达式
SELECT *
FROM `tableName`
WHERE `columnName` REGEXP '[^a-zA-Z0-9]'
This would select all the rows where the particular column contain atleast one non-alphanumeric character.
这将选择特定列包含至少一个非字母数字字符的所有行。
or
要么
REGEXP '[^[:alnum:]]'