【发布时间】:2016-08-03 13:45:10
【问题描述】:
下面是过程
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
这个过程的问题是我将如何传入age varchar(100), parameter in, in 子句 目前我正在使用查询进行解析
CALL `usitterz`.`sitter_price`(4.10,'1,2,3,4', 3, 5);
但这是错误的,因为在查询中像 in('1,2,3,4') 一样读取它,但我希望它像 - in(1,2,3,4)。
会是这样的
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
【问题讨论】: