我正在传递两个参数,我需要使用多个插入调用填充统计表。它不起作用,有人可以帮我解决这个问题吗?
CREATE PROCEDURE STAT(IN arg_From DATETIME, IN arg_End DATETIME)
INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,
stat_count,modified_on,created_on)
(SELECT -1 as source_id_fk ,3 as source_type, 1 AS stat_type_id_fk ,
COUNT( 1 ) AS stat_count, NOW( ) AS modified_on ,
NOW( ) AS created_on
FROM wall_posts WHERE post_type =1
and created_on >= arg_From
and created_on <= arg_End group by 1,2,3,5,6)
INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,stat_count,
modified_on,created_on)
(SELECT -1 as source_id_fk ,3 as source_type, 2 AS stat_type_id_fk ,
COUNT( 1 ) AS stat_count , NOW( ) AS modified_on ,
NOW( ) AS created_on
FROM wall_posts WHERE post_type =2
and created_on >= arg_From
and created_on <= arg_End group by 1,2,3,5,6);