一尘不染

mysql ::插入表中,来自另一个表的数据?

mysql

我想知道是否有一种方法可以完全在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万行。

有什么办法可以在直式sql中完成上述操作?要直接从一个表(基本上是原始数据表)中提取数据并插入到另一个表(基本上是已处理数据表)中?


阅读 272

收藏
2020-05-17

共1个答案

一尘不染

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'
2020-05-17