In
addition to inserting data one row at a time into a table, it is quite possible
to populate a table with data any exists in another table. The syntax for doing
so is as follows:
Syntax :
INSERT INTO
SELECT , FROM ;
Insert
data in the table ACCT_DTLS using the table ACCT_MSTR as a source of data.
INSERT
INTO ACCT_DTLS SELECT ACCT_NO, BRANCH_NO, CURBAL
FROM ACCT_MSTR;
5 rows created.
Insertion of A
Data Set Into A Table From Another Table
Syntax :
INSERT INTO SELECT ,
FROM WHERE
;
Example :
Insert only the
savings bank accounts details in the target table ACCT_DTLS.
INSERT INTO ACCT_DTLS SELECT
ACCT_NO, BRANCH_NO, CURBAL
FROM ACCT_MSTR WHERE ACCT_NO LIKE ‘SB%’;
Output:
3 rows created.
No comments:
Post a Comment