Page 1 of 1
Looking for something that does not CONTAIN a word. HOW?
Posted: Tue Mar 02, 2010 5:26 am
by simonmlewis
Code: Select all
SELECT id, title FROM products WHERE category != '%red%' ORDER BY title ASC
I am trying to run a query that checks the entire database table where a category name of a product does not have the word 'red' in it.
So if the category is called "red spot" or "blue and red stripe", it will not show it in the listing.
I thought it would be "DOES NOT CONTAIN" or something like that.
Anyone know?
Re: Looking for something that does not CONTAIN a word. HOW?
Posted: Tue Mar 02, 2010 5:35 am
by Eran
[sql]SELECT id, title FROM products WHERE category NOT LIKE '%red%' ORDER BY title ASC[/sql]
http://dev.mysql.com/doc/refman/5.1/en/ ... tions.html
Re: Looking for something that does not CONTAIN a word. HOW?
Posted: Tue Mar 02, 2010 5:36 am
by simonmlewis
Crikey - I knew it would be simple, but brain didn't think of that!!