How to use GROUP_CONCAT in Stored procedure MySQL -


i'm trying use comma separated values (@job_skills) in query follows in stored procedure. not work expected. amy consider first value comma separated string. there other way patch ?

select group_concat(skillid) job_skills tbljob_skill jskl jskl.jobpostingid = param_jobid @job_skills;

    block6: begin         declare curl_job12 cursor select * (select js.jobseekerid tbljobseeker_skill jss inner join tbmstjobseeker js on (js.jobseekerid = jss.jobseekerid) inner join tblrecommended_jobseekers_details rjd on (js.jobseekerid=rjd.jobseekerid) jss.skillid in (@job_skills) , js.isactive = 'y' , js.lat<>0 , js.lang<>0 , rjd.sessionid=param_sessionid group js.jobseekerid) m;         declare continue handler not found set job_done12 = true;         open curl_job12;             read_loop_job12: loop                 fetch curl_job12 jsid, miles;                 if job_done12                     leave read_loop_job12;                 end if;                 insert temp_skills (jobid,skill,jobseekerid) values (param_sessionid,@job_skills,jsid);                 if jsid <> ''                     select count(1) check_exists tblrecommended_jobseekers_details sessionid = param_sessionid , type = 'match 1 - skills' , jobseekerid = jsid;                     if check_exists = 0                         start transaction;                         insert temp_jobseekers_scores (jobseekerid,score,type,miles) values (jsid,score_skills,'match 1',miles);                         insert tblrecommended_jobseekers_details (jobseekerid,score,type,miles,sessionid) values (jsid,score_skills,'match 1 - skills',miles,param_sessionid);                         commit;                     end if;                 end if;             end loop;         close curl_job12;     end block6; 

generated comma separated values set , treated single string when used in function. instead have use find_in_set compare other values.

change where clause in cursor definition below.

declare curl_job12 cursor          select * (             select js.jobseekerid                tbljobseeker_skill jss               inner join tbmstjobseeker js                       on (js.jobseekerid = jss.jobseekerid)               inner join tblrecommended_jobseekers_details rjd                       on (js.jobseekerid=rjd.jobseekerid)               --  jss.skillid in (@job_skills)               find_in_set( jss.skillid, @job_skills )                 , js.isactive = 'y'                 , js.lat<>0                 , js.lang<>0                 , rjd.sessionid=param_sessionid               group js.jobseekerid         ) m; 

refer documentation:

  • find_in_set(str,strlist)
    • returns value in range of 1 n if string str in string list strlist consisting of n substrings

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -