开发者

Mysql Regex Problem

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 opposit开发者_开发知识库e 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.


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]'


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜