Jump to content

Why wont this work?


dominod

Recommended Posts

Hi !

 

I am trying this code:

   $query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND blocked != '%no%' ORDER BY hits DESC LIMIT 10 ";

 

The 'blocked' row has the following value: "se dk no uk es"

 

Now, what I want it to do is to NOT include that row IF it finds "no" in the blocked row... The problem is that it dont block it :/ It works if I dont use wildcard characters and the 'blocked' row = 'no' but I want to have multiple values in that row...

 

 

Thanks in advance :)

 

Link to comment
Share on other sites

maybe you can try

 

$query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND LOCATE(' no ', blocked) = 0 ORDER BY hits DESC LIMIT 10 "

 

if the 'no' is always in the middle of the string... wouldn't work if is in the borders.  assuming that 'no' will be no part of other part of the string just use LOCATE('no', blocked)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.