Page 1 of 1

SELECT WHERE field DOES NOT CONTAIN a string??? HOW?

Posted: Thu Dec 19, 2002 1:50 pm
by superwormy
I want to select only records where a field DOES NOT contain a string in it...

So for instance, the contents of the fields might be:

Record 1: 1, bla bla bla i rock http://www bla bla bla
Record 2: 2, wowzers that rocks bla balj
Record 3: 3, this rocks mysql is great http://www.blue


Now, I want to select all records where that field DOES NOT have http:// in it. So it should JUST SELECT RECORD 2.

Whats the syntax for that?

Posted: Thu Dec 19, 2002 4:30 pm
by Rob the R
You should be able to use "not like" to do this:

Code: Select all

select * from table
where field NOT LIKE '%http://%' ;
You can also do it with a regular expression using REGEX. See the MySQL docs at http://www.mysql.com/doc/en/String_comp ... tions.html