Last post Aug 23, 2016 08:46 AM by Cathy Zou
Aug 19, 2016 07:54 AM|Likhith.S|LINK
Hi i have 3 table A,B,C
where A is the parent Table , B is the Child of A
I need to move the data from A to C also Move Data from B to C using table A id...
I have plan of creating Store procedure to do this functionality.
If any one have came across this please guide me to achieve this.
Thanks in Advance
Aug 22, 2016 02:00 PM|RavindraG|LINK
insert into C (C.Col1,C.Col2, C.Col3)
select a.Col1,a.Col2, (select b.Col3 from b where b.id = a.id) from a
Aug 23, 2016 08:46 AM|Cathy Zou|LINK
From your description, I suggest you could use INNER JOIN and INSERT INTO syntax to insert data to table C from table A and B. The following query is a sample, you could refer to it:
INSERT INTO tableC ( tableA.CLOUMN1, tableA.CLOUMN2,tableB.CLOUMN3,tableB.CLOUMN4)
FROM tableA p
INNER JOIN tableB c ON c.Id = p.Id
For more information about INNER JOIN and INSERT INTO, you could refer to the link below:
And, for more information about how to create a stored produce, you could refer to the following link:
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.