WHERE Not in list

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 23   (RSS)

By ciaranmac - September 22

I have ran into some issues with a where clause. I am doing some AND calls, but I now I want to do another call to exclude items that are in the list returned in $ExcludeItems. I have tried this:
$ExcludeItems = 110, 98

AND num NOT IN ('$ExcludeItems')

But it doesn't work for me. For some reason it is only excluding the first in the list. Can anyone shed some light? Below is the full call.

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "product_location = '$CurrentLocation' AND product_category like '%$CurrentCID%' AND num NOT IN ('$ExcludeItems')",
'orderBy' => "title ASC",
'loadUploads' => true,
'allowSearch' => false,
))
Cheers,
Ciaran

By Djulia - September 22 - edited: September 22

Hi Ciaran, 

You can try :

$ExcludeItems = "110, 98";
$ExcludeItems = explode(",", $ExcludeItems); //Split a string by a string

`num` NOT IN(".mysql_escapeCSV($ExcludeItems).") 
Cheers,
Djulia