Hi guys, Im working on a bit of MySQL and was wondering if there is a way (without using php arrays or other) to search a table for a value (say 1) and return the rows which '1' wasnt found in. != wont work because the table contains more than one value.

In summary, i want to return the rows which a value isnt found in.

My applogies if this doesnt make sense, if youd like any more, just ask.


9 Years
Discussion Span
Last Post by tesuji

you can use full-text search if avaliable

select *
from table
where description not like ‘%1%’

to search in all the rows

select *
from table
where not exists(*, ‘1”’)

or you do dont have full text search avaliable you can go with function

not like
not exists


It depends on the data type of the attribute you demand to be excluded from result set, for examples

if numeric: ... where Attribute != number
if char: ...where Attribute != 'excludeme'
if char surrounded with other stuff: ... where Attribute NOT LIKE '%excludeme%'
if NULL ... where Attribute IS NOT NULL

if to exclude a set, for example a set of single char values:
... where Attribute NOT IN ('1', '2', ...)

There is also ANY, SOME, ALL, EXISTS, but this is just another thing.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.