View Full Version : Where 'in'?

08-29-2006, 11:23 AM
Hi everybody.

I have a stored procedure in MySql and I want to pass in a string (strCodes)of comma delimited codes, i.e. "'N', 'NC', 'NCA'" and then do a select along the lines of:

SELECT code FROM table WHERE code IN (strCodes);

However, this isn't returing the desired result. I've tried running the hard-coded sql (below) in query browser but that just gives "syntax error near '' "... which isn't helping either. Any ideas? Anybody?

FROM table
WHERE (codes IN ('N','NC','NCA'));

08-29-2006, 02:07 PM
that code won't produce an error. are you doing it in php or something? directly in your mysql client it won't throw an error.

what is the exact line you are running and what is the exact error?

08-29-2006, 03:56 PM
That semi-colon at the end of the query will produce a syntax error if you run it in phpMyAdmin. That might be your problem.

As for your original problem, what results are you getting, if not the desired ones?

08-30-2006, 09:50 AM
Thanks guys!