Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return rows where field contains non alpha-numeric characters

I am trying to extract all rows which contain a non alpha numeric character at it's most literal except allowing space. Any punctuation, brackets - square and round, currency symbols etc.

I have tried to adapt the advice as given here Return sql rows where field contains ONLY non-alphanumeric characters however using not LIKE '%[a-z0-9]%' returns rows with a space. Fine. I amend the regex to be not LIKE '%[a-z0-9 ]%' and I now have zero rows returned. What am I doing wrong?

like image 586
GavinP Avatar asked Jun 27 '16 10:06

GavinP


1 Answers

The question you are referring to is for SQL Server. To do what you want in SQL Server, you would do:

where col like '%[^a-zA-Z0-9]%'

The ^ in the like pattern matches any characters not in the list.

like image 160
Gordon Linoff Avatar answered Nov 03 '22 15:11

Gordon Linoff