Using QMF


Copying rows from one table into another using SQL statements

You can use an insert query to copy certain rows and columns from an existing table into another table.

You can add the rows to an existing table, or you can specify a new table name and create a new table that contains the rows you specify.

For example, the following insert query adds the ID number, name, department, and job columns for all employees in department 38 in the Q.STAFF table to the MYSTAFF table:

 INSERT INTO MYSTAFF (ID, NAME, DEPT, JOB)
 SELECT ID, NAME, DEPT, JOB
   FROM Q.STAFF
   WHERE DEPT = 38

After you run this query, QMF adds five new rows to the MYSTAFF table. For these employees, the YEARS, SALARY, and COMM columns contain null values, because QMF does not select these columns in the query. If you want to include all the data for a row, you must select all the columns in the table.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]