Jump to content

SELECT FROM db WHERE value!=$array


George Botley

Recommended Posts

Is it possible to achieve a similar thing to this...

 

SELECT FROM db WHERE value!=$array

 

My example code is this:

 

$browser_hide = array("1" => "YandexBot 0.0 for unknown");

$query = "SELECT * FROM hitlist_hits WHERE month='$month' AND browser!='$browser_hide' ORDER by id DESC";

 

Thanks Guys.

Link to comment
https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/
Share on other sites

Seriously, you waited a whole 12 minutes before bumping your thread. Perhaps the lack of responses is due to the lack of clarity in your request. I *assume* you are wanting to find records where the value does not exist in the values of the array.

 

The query would use the operator "NOT IN" followed by a list of values.

$values = "'" . implode("','", $browser_hide) . "'";
$query = "SELECT *
          FROM hitlist_hits
          WHERE month='$month'
            AND browser NOT IN ($values)
          ORDER by id DESC";

Archived

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

×
×
  • 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.