Re: Combining two tables into a view

From: <alan_at_kean.ucs.mun.ca>
Date: Wed, 21 Apr 1993 01:57:09 GMT
Message-ID: <1993Apr20.222709.1_at_kean.ucs.mun.ca>


In article <1r17scINN1kf_at_cronkite.cisco.com>, pkane_at_diablo.cisco.com (Peter Kane) writes:
> I have two tables with the same fields, such as:
>
> table1: so_num char(10), prod char(10), price number
>
> table2: so_num char(10), prod char(10), price number
>
> and I would like to create a view so that these two tables
> look like one table. I've tried creating a view where the
> 'as' clause has two selects and a 'plus' between them, but
> I couldn't get that to work.
>
> Any suggestions?
>
> Thanks,
>
> Peter
> pkane_at_cisco.com

Create the view in the following way

create view view_name as
select * from table1
union
select * from table2 ;

(( Please excuse any syntax errors, I don't have the SQL*Plus manual handy ))

The key to this SQL statement is the "UNION". This qualifier allows you to logically combine the contents of tables with like field names.

Alan Kearley
Sr. Programmer Analyst
alan_at_morgan.ucs.mun.ca Received on Wed Apr 21 1993 - 03:57:09 CEST

Original text of this message