Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Joining 2 tables to look like 1

Re: Joining 2 tables to look like 1

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Mon, 19 Jul 1999 21:52:21 +0800
Message-ID: <37932D95.4224@yahoo.com>


Tim Shute wrote:
>
> Hi group!
>
> Can anyone help me with the following problem?
>
> I have two tables with data definitions that are 90% identical. Is there any
> way using, for example, a view that I can present them as one set of data,
> with the common fields being merged into a new field, but the different
> fields being displayed separately?
>
> For example :-
>
> Table 1
> Name Null? Type
> Sample Data
> ------------------------------- -------- ----
> ----------------
> DOCUMENT_NO NOT NULL VARCHAR2(30)
> 1999/00070
> DOCUMENT_TYPE VARCHAR2(4)
> PFW
> WORK_TO_BE_DONE_LANG1 VARCHAR2(1000)
> Overhaul and maintenance
>
> Table 2
> Name Null? Type
> Sample Data
> ------------------------------- -------- ----
> ----------------
> DOCUMENT_NO NOT NULL VARCHAR2(30)
> 1999/00045O
> DOCUMENT_TYPE VARCHAR2(4)
> PFW
> WORK_TO_BE_DONE_LANG1 VARCHAR2(1000)
> Overhaul
> APPROVED_BY VARCHAR2(50)
> Tim Shute
> APPROVED_DATE DATE
> 19-JUL-1999 12:20:34
> OUTAGE_NO VARCHAR2(3)
> 272
>
> Required Output / Table / View
> e.g. SELECT DOCUMENT_NO, DOCUMENT_TYPE, APPROVED_BY FROM NEW_OBJECT;
>
> DOCUMENT_NO DOCUMENT_TYPE APPROVED_BY
> --------------------- ------------------------- ---------------------
> 1999/00070 PFW
> 1999/00045O PFW Tim Shute
>
> Thanks in advance
> --
> --
> Tim Shute
> Software Engineering Manager
>
> NiSoft (UK) Limited
> Unit 8, 31 Ballynahinch Road, Carryduff, BELFAST BT8 8EH
> Tel: +44 (0) 1232 814121, Fax: +44 (0) 1232 813962
> Internet: www.nisoft.co.uk

select a.common_col1, a.common_col2, a.other_cols, b.other_cols from table1 a, table2 b
where a.common_col1 = b.common_col1
and a.common_col2 = b.common_col2

(also handy if common columns are indexed)

HTH
--



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Mon Jul 19 1999 - 08:52:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US