Rubertos
Rubertos

Reputation: 129

How do I create a new table from query results?

Here is the code I am using;

select A.CD, A.NM
from TABLE A, TABLE B
where A.CD=B.CD
and A.NM <> B.NM;

And I want to create a table named "NEW_TABLE" having the above query results. (The above code means that I am selecting rows that are equal in the column "CD" but different in the column "NM")

I tried;

create table NEW_TABLE    
select A.CD, A.NM
from TABLE A, TABLE B
where A.CD=B.CD
and A.NM <> B.NM;

But the script says that there is a missing keyword.. How do I fix this?

Upvotes: 0

Views: 127

Answers (1)

Romeo Ninov
Romeo Ninov

Reputation: 7265

You should use AS keyword:

create table NEW_TABLE 
AS (select A.CD, A.NM
from TABLE A, TABLE B
where A.CD=B.CD
and A.NM <> B.NM);

Upvotes: 3

Related Questions