Is it possible to select data with a single query from a mysql table with a string of values? I have the following query and am trying to retrive results where the c.id_category is not equal to any of the values in the string.
which would consist of something like “1,67,23,34,65”
'SELECT DISTINCT c.*,
cl.*
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.intval($params['cookie']->id_lang).')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE 1'.(intval($maxdepth) != 0 ? '
AND `level_depth` <= '.intval($maxdepth) : '').'
AND (c.`active` = 1 OR c.`id_category`= 1)
AND c.`id_category` != VAR_ARRAY
AND cg.`id_group` '.(!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group
FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.intval($cookie->id_customer).')').'
ORDER BY `level_depth` ASC, cl.`name` ASC'
Something like:
SELECT * FROM Foo WHERE bar NOT IN (1,67,23,34,65);
sounds like it would fit your needs.