一次将数据插入到表中,然后从mySQL select命令中检索数据 [英] Insert data to table at once which retrieve from mySQL select command

查看:67
本文介绍了一次将数据插入到表中,然后从mySQL select命令中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have mentioned my Original transaction table and temporary Transaction Table I want to insert data to temporarytransaction table which I select values of Transaction table

    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)
    );

我想将此查询修改为可以使用的查询,这是我的问题

I want edit this query to working one That is my Question

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";

这篇关于一次将数据插入到表中,然后从mySQL select命令中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆