5

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?

froadie
  • 79,995
  • 75
  • 166
  • 235

1 Answers1

13

How about you add the space:

SELECT *
FROM myTable
WHERE myField LIKE '%[^a-zA-Z0-9 ]%'
Petar Ivanov
  • 91,536
  • 11
  • 82
  • 95
  • Now I'm confused (and feel silly). I thought I just tried that and it didn't work... But I just tried again and it did :-/ Maybe it's just too early in the morning... thanks! – froadie Jul 26 '11 at 07:29
  • It doesn't let me accept the answer yet... I will in about 8 minutes :) – froadie Jul 26 '11 at 07:30