Link to home
Start Free TrialLog in
Avatar of HyperBPP
HyperBPP

asked on

Combining two tables into single view or table

I have two tables.  Many of the columns are named the same.  I need to make a combined table or view with data from both tables.  How is the best done?  Something like:

CREATE VIEW myComboView
AS
   SELECT ColumnA, ColumnB
   From
      table1, table2

Suppose that table 1 and table 2 look like:

Table1
(ColumnA int, ColumnB int, ONEColumn int)

Table2
(ColumnA int, CloumnB int, TWOColumn int
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

You want to UNION them.
CREATE VIEW myComboView
AS
   SELECT ColumnA, ColumnB, 1
   From table1 
   union all
   SELECT ColumnA, ColumnB, 2
   From table2 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial