MYSQL SELECT WHERE IN issue
I am trying to use the WHERE fieldname IN ("#form.names#") but it won't work.
I know for example:
SELECT *
FROM tablename
WHERE
fieldname IN ('US,UK,GB,CN');
will NOT work, but
SELECT *
FROM tablename
WHERE
fieldname IN ('US','UK','GB','CN');
will work.
But here is my problem. I get the list from a form with checkboxes, so they are stored in a form variable call form.names. The form.names value is US.UK,GB,CN etc. So if I put
SELECT *
FROM tablename
WHERE
fieldname IN (#form.names#);
nothing will work, because there is no quotes around it but if I put the quotes
SELECT *
FROM tablename
WHERE
fieldname IN ("#form.names#");
will work ONLY if the list has one item. When there is more than one like the above, it won't work at all.
How can I manipulate the #form.names# so that each item will have quotes around it? Any help is appreciated.
