I have an array with ids
I have a query that needs to exclude those array ids
How?
Excluding results from an array, in a query
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
SELECT * FROM table WHERE id NOT IN('1','3','200','634')- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
there are functions and loops you can use to create that string.
viewtopic.php?t=29514 may be of interest..
viewtopic.php?t=29514 may be of interest..
Final code
Code: Select all
if($f)
{$string = str_replace(',', '', $f);
$string = implode("', '", $string);
$string = substr("$string", 3);
$string = "AND f.fid NOT IN($string')";}