Jump to content

Archived

This topic is now archived and is closed to further replies.

bayder

Is multiple "not like" possible?

Recommended Posts

Hi,

 

I am trying to create a query to filter out using \"not like\" now this is fine if I use a single \"not like\", but I always get an error when using a second or more.

 

for example

 

mysql_query(\"SELECT DISTINCT mystuff FROM table WHERE mystuff NOT LIKE \"%one%\" OR mystuff NOT LIKE \"%two%\"\");

 

which is strange because the \"like\" syntax works fine

 

eg.

mysql_query(\"SELECT DISTINCT mystuff FROM table WHERE mystuff LIKE \"%one%\" OR mystuff LIKE \"%two%\"\");

 

Can anyone enlighten me here please.

Share this post


Link to post
Share on other sites

Do ()\'s help? eg

 

SELECT DISTINCT mystuff FROM table 

WHERE ((mystuff NOT LIKE "%one%") 

OR (mystuff NOT LIKE "%two%")) " 

Share this post


Link to post
Share on other sites

Yes :)

 

SELECT DISTINCT mystuff FROM table

WHERE mystuff NOT LIKE (\"%one%\")

OR mystuff NOT LIKE (\"%two%\")\"

 

Thank you

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.