Re: Combining two tables into a view

From: <alacy_at_hayes.com>
Date: 21 Apr 93 07:05:22 EDT
Message-ID: <7179.2bd4f232_at_hayes.com>


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.

Try

	CREATE view1 as 
         SELECT so_num,prod,price
           FROM TABLE1
          UNION
          SELECT so_num,prod,price
           FROM TABLE2;

Note: If there are identical rows in TABLE1 and TABLE2 they will only show up once in the view.

-- 
Allen Lacy, Principal Analyst | internet:  alacy_at_hayes.com              
(404) 840-9200 (x.2131)       | uucp:      uunet!hayes!alacy     
Hayes Microcomputer Products  | U.S.Mail:  p.o.box 105203, Atlanta, GA 30348
Received on Wed Apr 21 1993 - 13:05:22 CEST

Original text of this message