sql while语句及procedure

2018-10-17  本文已影响137人  vlsee
CREATE PROCEDURE myProc()
BEGIN
    DECLARE num INT DEFAULT 0;
    DECLARE stime TIMESTAMP;
    DECLARE etime TIMESTAMP;
    DECLARE cnt INT DEFAULT 0;
    WHILE num<90 DO
        SET stime="2018-07-01 00:00:00" + INTERVAL num DAY;
        SET etime="2018-07-01 23:59:59" + INTERVAL num DAY;
--      SELECT count(*) INTO cnt FROM usertpiactivity where time>=stime and time<=etime;
--      INSERT INTO temp SET period=num,utpicount=cnt;
--      SELECT count(*) INTO cnt FROM usertpisactivity where time>=stime and time<=etime;
--      UPDATE temp SET utpiscount=cnt where period=num;
        UPDATE temp SET day=stime where period=num;
        SET num=num+1;
    END WHILE;
END
上一篇 下一篇

猜你喜欢

热点阅读