我已经提到了我的原始事务表和临时事务表,我想将数据插入到临时事务表中,我选择事务表的值

    CREATE TABLE Transaction(
    Tid int auto_increment primary key,
    T_type varchar(20),
    Amount decimal(10,2),
    Tdate DATETIME,
    accountNo int,
    CONSTRAINT FOREIGN KEY(AccountNo) REFERENCES Account(AccountNo)
    );



CREATE TABLE tempTransaction(
    Tid int auto_increment primary key,
    T_type varchar(20),
    Amount decimal(10,2),
    Tdate DATETIME,
    accountNo int,
    CONSTRAINT FOREIGN KEY(AccountNo) REFERENCES Account(AccountNo)
    );

我想将此查询编辑为工作查询这是我的问题
INSERT INTO temporarytransaction VALUES (SELECT * FROM Transaction WHERE `Tdate` BETWEEN "2012-03-15" AND "2016-03-31");

最佳答案

不要把values()放进去;http://dev.mysql.com/doc/refman/5.6/en/insert-select.html

INSERT INTO temporarytransaction SELECT * FROM Transaction WHERE `Tdate` BETWEEN "2012-03-15" AND "2016-03-31";

关于php - 一次将数据插入表中,然后从mySQL select命令中检索数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30290438/

10-12 13:26