tags:

views:

54

answers:

1

How can I evaluate whether a column contains any non-ascii characters in mysql? In this case the charset is actually latin1, so I'm just looking for high-byte chars.

I tried this:

select * from company where ticker regexp concat('[', x'7f', '-', x'ff', ']')

but this returns this error:

ERROR 1139 (42000): Got error 'invalid character range' from regexp

+1  A: 

There must be an easier way to do this, but all the typical escapes I thought would work, didn't. So here is one, ugly solution:

select * from company 
where ticker regexp(concat('[',char(128),'-',char(255),']'));
Paul Dixon