Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (20.3k points)

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

Note: q1 would return about 30k rows.

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 it into another table (basically a processed data table)?

1 Answer

0 votes
by (40.7k points)

Try using this code:

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'

Browse Categories