SELECT company_id FROM companies WHERE company_id IN (#ValueList(GetProducts.company_id)#)
The problem is the list of company ids in the GetProducts query are sometimes NULL and the above query results in the error: Incorrect syntax near ','.
The SQL looks like this:
SELECT company_id FROM companies WHERE company_id IN (302,307,235,,514,154,,421)
I have tried writing an IF statement to compile the list if the company_id is not NULL but have run into problems with commas â€“ especially if the last record is NULL.
Does anyone know how to get the second query to ignore the NULL records or a sound alternative?