Friday, February 17, 2012

DB: Insert with a select

Inspite of so many years into db i still found i didnt knew this one :)

Aim: To write an insert after selecting from some other table.

SQL:
INSERT INTO A (column1, col2, col3)
SELECT otherCol1, otherCol2, otherCol3
From table
Where condition here

To Note: no use of the normal 'VALUES' kyword

No comments: