SELECT * from tablename where url <> 'club.youshang.com' and url REGEXP '^[[:alnum:]]+\.youshang\.com$';
简单点的。select * from a where `name` regexp '^.*(http://youshang.com){1}.*$';
非常感谢楼上的两位,我这里面不能用AND 才想到用正则的 4楼的没有明白我的意思,我再讲明白点:我其实要的效果是: select * from a where `name` where name like '%youshang.com%' and name not like '%club.youshang.com%' 由于某种原因,现在我想就用一个正则来搞定,但不知道如何写?
你可能要的是这个sql吧select * from a where `name` where name regexp '.*[^club]\.youshang.com'
select * from a where `name` where name regexp '.*[^club]\.youshang\.com.*'
又弄错了,汗……select * from a where `name` where name regexp '[^club]\.youshang.com'
错,这会把 c.youshang.com b.youshang.com 等过滤了
楼主的意思是这样吧。 select * from a where `name` regexp '^[^\.]*(youshang.com)+.*$'
4楼的没有明白我的意思,我再讲明白点:我其实要的效果是: select * from a where `name` where name like '%youshang.com%' and name not like '%club.youshang.com%'
由于某种原因,现在我想就用一个正则来搞定,但不知道如何写?
select * from a where `name` where name regexp '.*[^club]\.youshang\.com.*'
select * from a where `name` regexp '^[^\.]*(youshang.com)+.*$'