tags:

views:

12

answers:

2

I want to find only those rows whose column 'col' c doesn't contain characters from a-1. So I don't know how to write script. I've succeed to write script which is opposite to this. Thanks in Advance.

select * 
  from tbl_comment c 
 where c.`message` regexp '{a-z}';

I need the script which will be opposite to this. I've tried "not regexp" but it doesn't work.

+2  A: 

You need square brackets, not braces:

SELECT *
FROM tbl_comment c
WHERE c.`message` NOT REGEXP '[a-z]'

You also need to be careful what you mean. The above matches any row that doesn't contain any letters in a-z. If instead you want to match rows that contain at least one character not in a-z then you need this instead:

SELECT *
FROM tbl_comment c
WHERE c.`message` REGEXP '[^a-z]'
Mark Byers
+1  A: 

Try:

select * from tbl_comment c where c.message regexp '[^A-Z]'

or:

select * from tbl_comment c where c.message not regexp '[A-Z]'

Character class specifiers should be in square brackets.

(I'm assuming you meant "A-Z", not "A-1")

Seth