Mr.Song Mr.Song - 4 months ago 8
SQL Question

how to make Table C by Table A,B

Question



how to make Table C by Table A,B.

just on query.


ex) this query not working.


insert into C (mySring_A , mySring_B)
values (any(select Table_A.mySring_A from Table_A) ,
any(select Table_B. mySring_B from Table_B)
);


DB Table



Table_A

+ idx

+ mySring_A


Table_B

+ idx

+ mySring_B


Table_C

+ idx

+ mySring_A

+ mySring_B

Answer

If you want to insert all combinations of strings from the two tables, use insert . . . select:

insert into C(myString_A, myString_B)
    select a.myString_A, b.myString_B
    from Table_A a cross join
         Table_B b;