MySql stored procedure with list paramater

Viewed 30

lets say i have table like this :

ID VALUE
1  "abc,def"
2  "xyz,ghi,jkl"

if i want to select i can do like this :

select * from my_table where value like '%ghi%' or '%def'

but how to make it stored procedure with parameter 'ghi,def' and call like this : call SP_GetValue('ghi,def');

i try to make stored procedure for iterating parameter

set @KEYWORD = 'ghi,def' ;
drop temporary table if exists temp;
create temporary table temp( val char(255) )  ENGINE=MEMORY;
set @sql = concat("insert into temp (val) values ('", replace(( select @KEYWORD), ",", "'),('"),"');");
select @sql;
prepare stmt1 from @sql;
execute stmt1;

select distinct(val) from temp; 

any help appreciate.

0 Answers
Related