Need to insert columns from one table into two tables

  • Hello -
    I have Table A with four columns - two of which have to go into Table B and two of which have to go into Table C.
    Table B and Table C can be joined on ID = ID.  What is the best way to do this?

    Any help will be greatly appreciated!

    Junior Mint

  • slsmithstone - Wednesday, June 13, 2018 2:27 PM

    Hello -
    I have Table A with four columns - two of which have to go into Table B and two of which have to go into Table C.
    Table B and Table C can be joined on ID = ID.  What is the best way to do this?

    Any help will be greatly appreciated!

    Junior Mint

    insert into table B
    and
    insert into table C

    Sue

  • Sue_H - Wednesday, June 13, 2018 2:36 PM

    slsmithstone - Wednesday, June 13, 2018 2:27 PM

    Hello -
    I have Table A with four columns - two of which have to go into Table B and two of which have to go into Table C.
    Table B and Table C can be joined on ID = ID.  What is the best way to do this?

    Any help will be greatly appreciated!

    Junior Mint

    insert into table B
    and
    insert into table C

    Sue

    Well you at least need a SELECT ID, Col1, Col2 from A somewhere 😀
    insert into B
    select ID, Col1, Col2 from A
    insert into C
    select ID, Col3, Col4 from A

    Cheers
    Leo
    Nothing in life is ever so complex that with a little work it can't be made more complex!

    Leo
    Nothing in life is ever so complicated that with a little work it can't be made more complicated.

  • Leo.Miller - Thursday, June 14, 2018 4:43 PM

    Sue_H - Wednesday, June 13, 2018 2:36 PM

    slsmithstone - Wednesday, June 13, 2018 2:27 PM

    Hello -
    I have Table A with four columns - two of which have to go into Table B and two of which have to go into Table C.
    Table B and Table C can be joined on ID = ID.  What is the best way to do this?

    Any help will be greatly appreciated!

    Junior Mint

    insert into table B
    and
    insert into table C

    Sue

    Well you at least need a SELECT ID, Col1, Col2 from A somewhere 😀
    insert into B
    select ID, Col1, Col2 from A
    insert into C
    select ID, Col3, Col4 from A

    Cheers
    Leo
    Nothing in life is ever so complex that with a little work it can't be made more complex!

    I didn't see any DDL with column names so I'm not aware of Col1, Col2 and wouldn't know which columns are to be inserted into which tables. Glad you figured it out though 😀

    Sue

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply