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
  • 160,735
  • 37
  • 279
  • 278
Dhruv
  • 9,575
  • 18
  • 73
  • 122

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.
  • 62,344
  • 41
  • 131
  • 195
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,103
  • 20
  • 32