Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I search for rows that contain a non-alphanumeric or space character?

I want to search a table for all rows that contain a non-alphanumeric and non-space character in a specific field. What I have so far:

SELECT *
FROM myTable
WHERE myField LIKE '%[^a-zA-Z0-9]%'

As far as I can tell, this returns all non-alphanumeric fields. However, spaces are fine, so I don't want to return rows where the only non-alphanumeric character is a space. How can I adjust this query?

like image 957
froadie Avatar asked Jul 26 '11 07:07

froadie


1 Answers

How about you add the space:

SELECT *
FROM myTable
WHERE myField LIKE '%[^a-zA-Z0-9 ]%'
like image 169
Petar Ivanov Avatar answered Sep 30 '22 17:09

Petar Ivanov