IN query in MYSQL Function -
i m in situation need pass comma separated project ids stored procedure function
stored procedure
create procedure `spgetdata`( ) begin set session group_concat_max_len = 10000000; set @leadprojectids = (select distinct cast(group_concat(projectid separator ',') char(10000000)) project pr status = 2); select fncount(@leadprojectids) count; end
and function is
create function `fncount`( _projectids varchar(800) ) returns decimal(10,2) begin set @leadscount = (select count(*) project projectid in(_projectids)); homecoming @leadscount; end
but above function not homecoming count.
the sp , function mentioned here example, m using function info because has many more conditions , bring together mentioned here.
so want know, how can pass projectids 1,2,3,4 , result function in mysql.
try using instr
function:
create function `fncount`( _projectids varchar(800) ) returns decimal(10,2) begin set @leadscount = (select count(*) project instr(_projectids, concat(',', projectid, ',')) > 0); homecoming @leadscount; end
just sure every projectid within _projectids parameter has format ,projectid,
. additionally, aware there limit of project ids concatenated on string, blow @ point.
mysql
No comments:
Post a Comment