Rick James
Rick James

Reputation: 237

Combining 2 SQL Tables

I have the following 2 tables:

temp_table w/ columns MAIN_AUTHOR, COLLAB_NAME, COLLAB_ID, RESEARCH_ID
people_person w/ columns id, MAIN_AUTHOR, COLLAB_NAME, COLLAB_ID, RESEARCH_ID

temp_table contains data, people_person does not. I want to put all the rows from temp_table into the corresponding columns in people_person. Ive tried different joins but I dont know what kind of join to use/ how to do it. Thanks

Upvotes: 0

Views: 39

Answers (1)

juergen d
juergen d

Reputation: 204894

I assume your id column in people_person is auto-increment. So

insert into people_person (MAIN_AUTHOR, COLLAB_NAME, COLLAB_ID, RESEARCH_ID)
select MAIN_AUTHOR, COLLAB_NAME, COLLAB_ID, RESEARCH_ID
from temp_table 

Upvotes: 1

Related Questions