是这样,两个表,本人要每天自动将一个表的字段数据的和插入到另一个表中,然后自身清零。表达能力有限 上图说话
解决方案
20
只考虑存储过程每天只执行一次
DELIMITER $$
CREATE PROCEDURE PRO_TEST()
BEGIN
INSERT INTO a(id, DATE, ratio, totalmoney)
VALUES
(“1”, NOW(), “1”, (SELECT SUM(daymoney) FROM b));
DELETE FROM b;
END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE PRO_TEST()
BEGIN
INSERT INTO a(id, DATE, ratio, totalmoney)
VALUES
(“1”, NOW(), “1”, (SELECT SUM(daymoney) FROM b));
DELETE FROM b;
END$$
DELIMITER ;
20
DELIMITER $$
CREATE PROCEDURE PRO_TEST()
BEGIN
INSERT INTO a(id, DATE, ratio, totalmoney)
VALUES
(“1”, NOW(), “1”, (SELECT SUM(daymoney) FROM b));
UPDATE b set daymoney=””;
END$$
DELIMITER ;
CREATE PROCEDURE PRO_TEST()
BEGIN
INSERT INTO a(id, DATE, ratio, totalmoney)
VALUES
(“1”, NOW(), “1”, (SELECT SUM(daymoney) FROM b));
UPDATE b set daymoney=””;
END$$
DELIMITER ;