我只是为了对比才把日期放前面 ,修改后还是不行的 DROP TABLE IF EXISTS tmp_product; CREATE TEMPORARY TABLE tmp_product( productid VARCHAR(40) , hottype int);
set @todate = '2019-08-26'; INSERT into tmp_product SELECT product_id,fn_saleshottype_V3(@todate,product_id) FROM ads_productdaliy_report ; -- where right(statisticalmonth,2) =month(@todate);
就是先执行SET,再执行INSERT。
DROP TABLE IF EXISTS tmp_product;
CREATE TEMPORARY TABLE tmp_product(
productid VARCHAR(40) ,
hottype int);
set @todate = '2019-08-26';
INSERT into tmp_product
SELECT product_id,fn_saleshottype_V3(@todate,product_id) FROM ads_productdaliy_report ;
-- where right(statisticalmonth,2) =month(@todate);
select * FROM tmp_product;