Hi David,
I have two tables that have maintain by two groups and recently found
out that they overlap to some extend. The column-A that I represented
was a user name column. I cant say exactly what the column-B and
column-D are due to information policy :( but lets say its a contact
info or some number. But I how could we accomplish without a union..?
Thanks alot.
Anu
On Oct 14, 8:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Oct 13, 11:35 pm, JNewMember <[EMAIL PROTECTED]> wrote:
>
>
>
> > I want to do a merge over a common column, lets say i have two tables
> > that reflect fallowing structure.
>
> > Table 1 Table
> > 2
> > Column-A Column-B Column-
> > A Column-D
> > --------------- ---------------
> > ----------------- ----------------
> > 0001 233
> > 0003 67000
> > 0003* 3000
> > 0006 5500
> > 0002 80
> > 0001 45000
> > 0003 (not mistake) 5000
>
> > So Column-A can have same value twice (not Unique - I know bad design-
> > This is more of data extraction). Also table 2 has the same Column-A.
>
> > I was thinking to do a union such as
> > Select Column-A, Column-B from Table1 union select Column-A, Column-D
> > from table2
>
> > is this the bast way to do..?
>
> > Thanks,
>
> What, exactly, do you want as your end result? A UNION will do just
> that, UNION the results, preserving unique rows:
>
> SQL> create table table_1
> 2 ( column_A varchar2(6)
> 3 column_B number);
>
> Table created.
>
> SQL>
> SQL> create table table_2
> 2 ( column_A varchar2(6)
> 3 column_D number);
>
> Table created.
>
> SQL>
> SQL> insert all
> 2 into table_1
> 3 values('0001', 233)
> 4 into table_1
> 5 values('0003', 3000)
> 6 into table_1
> 7 values('0002', 80)
> 8 into table_1
> 9 values('0003', 5000)
> 10 into table_2
> 11 values('0003', 67000)
> 12 into table_2
> 13 values('0006', 5500)
> 14 into table_2
> 15 values('0001', 45000)
> 16 select * From dual;
>
> 7 rows created.
>
> SQL>
> SQL> commit;
>
> Commit complete.
>
> SQL>
> SQL> select
> 2 column_a,
> 3 column_b
> 4 from
> 5 table_1
> 6 union
> 7 select
> 8 column_a,
> 9 column_d
> 10 from table_2;
>
> COLUMN COLUMN_B
> ------ ----------
> 0001 233
> 0001 45000
> 0002 80
> 0003 3000
> 0003 5000
> 0003 67000
> 0006 5500
>
> 7 rows selected.
>
> SQL>
>
> Is this how you want these results to appear? Are you certain that
> associating a given 'key' value with multiple results is the desired
> output? What, exactly, do these tables contain? Why is this
> 'process' necessary? You have much to explain before any usable
> answer can be given.
>
> David Fitzjarrell
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---