I have the following query (and it works fine):
SELECT cd.id AS card_id,
ct.id AS category_id,
COUNT(cc.user_id) AS cnt
FROM uiCards AS cd
JOIN uiCardCategories AS ct USING (project_id)
LEFT JOIN uiCategories2Cards AS cc ON (cc.card_id = cd.id AND cc.stack_id = ct.id)
WHERE cd.project_id = $projID
GROUP BY cd.id, ct.id
ORDER BY cd.id, ct.id
I also have a sting of numbers:
$exclude = '100,122,345';
I need to modify the string too exclude results found in the string. So I added:
AND cc.user_id NOT IN ($exclude)
below WHERE
WHERE cd.project_id = $projID
AND cc.user_id NOT IN ($exclude)
It did not seem to work, so I tried to modify more, and the whole query collapsed on me.
UPDATE:
I got it! I added quotes:
AND (FIND_IN_SET(cc.user_id, '$exclude') = 0 OR FIND_IN_SET(cc.user_id, '$exclude') IS NULL)
echo mysql_error();after the query.