mysql ::插入表中,来自另一个表的数据? [英] mysql :: insert into table, data from another table?
本文介绍了mysql ::插入表中,来自另一个表的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有一种方法可以完全在sql中完成:
I was wondering if there is a way to do this purely in sql:
q1 = SELECT campaign_id, from_number, received_msg, date_received
FROM `received_txts` WHERE `campaign_id` = '8';
INSERT INTO action_2_members (campaign_id, mobile, vote, vote_date)
VALUES(q1.campaign_id, q1.from_number, q1.received_msg, q1.date_received);
注意: q1将返回约3万行.
Note: q1 would return about 30k rows.
有什么方法可以在直式sql中做以上尝试吗? 要直接从一个表(基本上是原始数据表)中提取数据并插入到另一个表(基本上是已处理数据表)中?
Is there any way to do what I am attempting above in straight sql? To just pull the data straight from one table (basically a raw data table) and insert into another table (basically a processed data table)?
推荐答案
INSERT INTO action_2_members (campaign_id, mobile, vote, vote_date)
SELECT campaign_id, from_number, received_msg, date_received
FROM `received_txts`
WHERE `campaign_id` = '8'
这篇关于mysql ::插入表中,来自另一个表的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文