Re: Multiple queries into a single temp table
Posted in 1998
In article <350713BC.5E235B09@dgs.dgsys.com>,
Steve Dussinger <sdussin@dgs.dgsys.com> wrote:
>
> I tried the following:
>
> select 1 col1, dealer_id col2 from dealer into temp
>dlr_manu_tbl;
> select 2 col1, manufacturer_id col2 from manufacturer into temp
>dlr_manu_tbl;
>
> This failed, telling me that the table dlr_manu_tbl exists when the
>second select runs.
Do it like this:-
select 1 col1, dealer_id col2
from dealer
into temp dlr_manu_tbl;
insert into dlr_manu_tbl
select 2 , manufacturer_id
from manufacturer;
"insert into ... select ..." puts data into an existing temp table rather
than creating a new one. "select ... into temp ...." (and "create temp
table ....") both create new temp tables.
Or you could do this instead:-
select 1 col1, dealer_id col2
from dealer
union
select 2 , manufacturer_id
from manufacturer
into temp dlr_manu_tbl;
- Paul (not a spokesman)