SQL INSERT INTO from multiple tables

前端 未结 7 625
清歌不尽
清歌不尽 2020-12-02 12:17

this is my table 1:

NAME       AGE        SEX        CITY             ID

Clara      22         f          New York         1
Bob        33         m                 


        
相关标签:
7条回答
  • 2020-12-02 13:15

    If I'm understanding you correctly, you should be able to do this in one query, joining table1 and table2 together:

    INSERT INTO table3 { name, age, sex, city, id, number}
    SELECT p.name, p.age, p.sex, p.city, p.id, c.number
    FROM table1 p
    INNER JOIN table2 c ON c.Id = p.Id
    
    0 讨论(0)
提交回复
热议问题