mysql script for dynamic running sql script
1591 ワード
CREATE DEFINER=`root`@`localhost` PROCEDURE `getData`(deviceName varchar(45),startTime datetime,endTime datetime)
BEGIN
set @s1 = concat('SELECT * FROM ', deviceName , ' where view_time between ''' , startTime , ''' and ''' , endTime ,''' ;');
prepare s2 from @s1;
execute s2;
END