Jump to content


Photo

Is multiple "not like" possible?


  • Please log in to reply
2 replies to this topic

#1 bayder

bayder
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 October 2003 - 06:49 AM

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.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 27 October 2003 - 08:11 AM

Do ()\'s help? eg

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

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 bayder

bayder
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 October 2003 - 10:44 AM

Yes :)

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

Thank you




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users