0

I am using MySQL database.

Supposedly I have 3 table.

Table A : column ida
Table B : column idb
Table C: column A,B

I want to write a single through which I can insert values from Table A and Table B to Table C ??

D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283
Dhruv
  • 10,291
  • 18
  • 77
  • 126

2 Answers2

2

It should be something like this

insert into tablec
select a.ida, b.idb
from tablea a
inner join tableb b on -- relation between tablea and tableb

but you'll have to finish inserting the relation between tables.

aF.
  • 64,980
  • 43
  • 135
  • 198
0
INSERT INTO C SELECT id1, id2 FROM A, B WHERE ...

I'm assuming that C has only tow columns and they are of same datatype as that of id1 and id2 from tables A and B. I hope you get the idea.

naresh
  • 2,113
  • 20
  • 32