Sunday, March 25, 2012

create table

Hi
How to create a table by selecting data from different tables.
Can we create table with actual data while selecting data from different
tables. If yes what is the syntex.
============= Syntex for createing a view is
create view as
SELECT table1.code1, table1.field1, table2.field2
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
=============
Thanks
Jpr> How to create a table by selecting data from different tables.
> Can we create table with actual data while selecting data from different
> tables. If yes what is the syntex.
> =============> Syntex for createing a view is
> create view as
> SELECT table1.code1, table1.field1, table2.field2
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> =============
This is not tested, but the construct SELECT INTO should do it:
SELECT table1.code1, table1.field1, table2.field2 INTO newTable
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
/Sjang|||On Nov 28, 1:27 am, "Henrik Davidsen" <n...@.none.dk> wrote:
> > How to create a table by selecting data from different tables.
> > Can we create table with actual data while selecting data from different
> > tables. If yes what is the syntex.
> > =============> > Syntex for createing a view is
> > create view as
> > SELECT table1.code1, table1.field1, table2.field2
> > FROM
> > table1 INNER JOIN table2 ON table1.code1 = table2.code1
> > =============> This is not tested, but the construct SELECT INTO should do it:
> SELECT table1.code1, table1.field1, table2.field2 INTO newTable
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> /Sjang
Note that the target table wont have the indices that source table hassql

No comments:

Post a Comment