Consider that we want to make a temporary table with some information from an existing table.
Simple two-query method:
- Create the table (Create Table (SQL))
CREATE TABLE WORKS_ON_INFO (
NAME VARCHAR(15),
PROJECT VARCHAR(15),
HOURS_PER_WEEK DECIMAL(3,1),
)- Load the table with the results of a joined query (Insert Query (SQL))
INSERT INTO WORKS_ON_INFO (NAME, PROJECT, HOURS_PER_WEEK)
SELECT E.name, P.name, W.hours
FROM PROJECT P, WORKS_ON W, EMPLOYEE E
WHERE P.number = W.no AND W.essn = E.ssn;Complex one-query method: (Create Table (SQL) with Select Query (SQL))
CREATE TABLE WORKS_ON_INFO AS
SELECT E.name, P.name, W.hours
FROM PROJECT P, WORKS_ON W, EMPLOYEE E
WHERE P.number = W.no AND W.essn = E.ssn;