Lewis Smith Lewis Smith - 1 year ago 66
MySQL Question

Select * but no results containing "This"

Is there a way in sql to write a query that returns all results other than ones containing "This"

So in my mind it would look something like this but I know it doesn't work

$sql = 'SELECT * FROM tablename EXCLUDING WHERE col1 = This'

I know the above won't work, but is there something similar that will, can't seem to find anything on here to help

Answer Source

Try using NOT LIKE:

$sql = 'SELECT * FROM tablename WHERE col1 NOT LIKE "%This%"'

From w3resource:

MySQL NOT LIKE is used to exclude those rows which are matching the criterion followed by LIKE operator.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download