0

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.

1
  • Is a-1 a typo in your question? Should that be a-z? Commented Aug 30, 2010 at 2:40

2 Answers 2

2

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]'
Sign up to request clarification or add additional context in comments.

Comments

1

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")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.