我想根据存储过程中的一个参数来更改此SQL语句中的间隔。我想使用三种不同的时间间隔:1天,8小时,1小时
CREATE DEFINER= 'dbshizzle' PROCEDURE `getData`(in sD text(17), in sT text(8))
BEGIN
select stime, sval
from tblNumber
where sDix = 'allright'
and timestamp >= now() - interval 1 day
order by timestamp;
END
我应该使用带有整数参数或文本参数的IF语句吗?
发布于 2017-03-01 14:38:00
调整参数并以小时为单位传入值如何?
CREATE DEFINER = 'dbshizzle' PROCEDURE `getData`(
in in_sD text(17), -- should change to varchar
in in_sT text(8), -- should change to varchar
in in_hours int
)
BEGIN
select stime, sval
from tblNumber
where sDix = 'allright'
and timestamp >= now() - interval in_hours hour
order by timestamp;
END;
https://stackoverflow.com/questions/42534390
复制相似问题