How to use concated variable into mysql query inside mysql stored procedure? -


i have concat string in mysql stored procedure. , want use string in clause in same stored procedure. when i'm using it, i'm getting first value comma separated string (1,2,3). can't understand why happens , solution it. if knows reason , solution, answer appreciated. here code of stored procedure.

declare newids varchar(255);  select group_concat(id) newids temptblnewcustomers;  drop table if exists temptblcustomerspurchase; create table temptblcustomerspurchase (b_id bigint(20), b_customer bigint(20), a_item varchar(50)); insert temptblcustomerspurchase(b_id, b_customer, a_item)     select b.id b_id, b.customer_id b_customer, a.item a_item purchases join (         select id, customer_id, item (             select id, customer_id, item purchases customer_id in (newids) order customer_id, id desc) t          group customer_id) b     on a.item=b.item; 

here, temptblnewcustomers consists 1 column 5 rows having value id. , in newids, i'm geting values 2301,2302,2303. when i'm using newids in (), takes onle first id i.e, 2301. think there may reason of newids datatype varchar , id of temptblnewcustomers bigint. i'm not sure can affect.

you can use select query directly in where in clause.


Comments