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.

Fost

Recommended Answers

All 2 Replies

you can use full-text search if avaliable

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

or
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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.