below is the procedure
CREATE DEFINER=`root`@`localhost` PROCEDURE `sitter_price`(
in in_hours float,
in age varchar(100),
in no_of_sitters int,
in no_of_days int
)
BEGIN
select
TRUNCATE(sum(price)*in_hours*no_of_days*no_of_sitters,2) as
total_amount
from job_prices jp
join kids_ages ka on ka.id = jp.kids_age_id
where ka.age in(age) and start_hours > in_hours
AND in_hours <= end_hours;
END
The problem is in this procedure is how I will pass in age varchar(100), parameter in, in clause currently I am parsing using the query
CALL `usitterz`.`sitter_price`(4.10,'1,2,3,4', 3, 5);
but this is wrong because in query read this like in('1,2,3,4') but I want it like - in(1,2,3,4).
it will be like
CREATE DEFINER=`root`@`localhost` PROCEDURE `sitter_price`(
in in_hours float,
in age varchar(100),
in no_of_sitters int,
in no_of_days int
)
BEGIN
select
TRUNCATE(sum(price)*in_hours*no_of_days*no_of_sitters,2) as
total_amount
from job_prices jp
join kids_ages ka on ka.id = jp.kids_age_id
where ka.age in(1,2,3,4) and start_hours > in_hours
AND in_hours <= end_hours;
END