insert value to new table by joining 2 different tables 1

insert value to new table by joining 2 different tables

INSERT INTO table ( col1 , col2, col3, col4)
SELECT p.col1, p.col2, c.col3, c.col4
FROM table1 p
INNER JOIN table2 c ON c.Id = p.Id

Here is what the above code is Doing:
1. It’s creating a new table called table.
2. It’s inserting the columns col1, col2, col3, col4 into the new table.
3. It’s selecting the columns col1, col2, col3, col4 from the table1 and table2.
4. It’s joining the two tables on the Id column.

Similar Posts