Variables such as a comma delimited strings cannot be embedded in Mysql queries. For example say you want you have a list of store id’s ”32,43,53,66″ and you want to create a query whith where StoreID is in this list.

The only way to do this is to use a dynamic query. Here is an example.

-- use dynamic query for multiple store/group list.
set @sql = concat('select StoreID, Date, Item, Price ) from myStoreChain where StoreID in(', vStoreList, ') and Date between ', quote(vStart), ' and ', quote(vEnd));
prepare query from @sql;
execute query;
deallocate prepare query;