View previous topic :: View next topic
|
Author |
Message |
Biswajit Nanda
New User
Joined: 28 Mar 2011 Posts: 9 Location: India
|
|
|
|
IS UNINON = OUTER jOIN? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
no, although some idiots use full outer join when a union is required. |
|
Back to top |
|
|
Biswajit Nanda
New User
Joined: 28 Mar 2011 Posts: 9 Location: India
|
|
|
|
Please,can you give me details, why its different? |
|
Back to top |
|
|
mallik_0279
New User
Joined: 13 Aug 2007 Posts: 4 Location: hyderabad
|
|
|
|
hello,
pls post your question clearly..
so that members can help you |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
As GuyC said "No" -- to take it further, in a join, the matching rows are joined side-by-side to make the result table. By contrast, in a union the matching rows are joined (in a sense) one-above-the-other to make the result table.
Hope you've the answer? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10874 Location: italy
|
|
|
|
I like to think the UNION along the lines of a <datatset> CONCATENATION |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
The output record set in union contains same number of columns as in the input tables. But it concatenates all the records of both the input tables in the output. Both the input tables should have the same number of columns and same data types for those columns.
But the full outer join concatenates the columns in both the table. No need for the input tables to have same number of records.
a full outer join combines the results of both left and right outer joins. The joined table will contain all records from both tables, and fill in nulls for missing matches on either side |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
gylbharat wrote: |
The output record set in union contains same number of columns as in the input tables. But it concatenates all the records of both the input tables in the output. Both the input tables should have the same number of columns and same data types for those columns.
But the full outer join concatenates the columns in both the table. No need for the input tables to have same number of records.
a full outer join combines the results of both left and right outer joins. The joined table will contain all records from both tables, and fill in nulls for missing matches on either side |
close, but no cigar.
- The tables in a union don't have to have the same number of columns or "records". The selects in a union must specify the same number and compatible types of columns!
a union will show duplicate rows only once, a union all will show duplicate rows if they exist.
in enrico-sorichetti words :
a union is like concatenate datasets and a sort sumfields=none
a union all is like concatenate datasets
- a full outer join will contain all rows from both tables, but depending on your join condition, the same row can be reported multiple times.
in enrico-sorichetti words : a full outer join is like a 2 datasets merge program.
So functionally different things.
Sure you can do a union using a full outer join and a lot of coding.
Sure you can do a full outer join using a union and a lot of coding.
But that is just stupid. |
|
Back to top |
|
|
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
The answer is "It is not". |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
removed by poster.
no need to duplicate guyc's response,
other to add:
and db2 tables do not have records, they have rows. |
|
Back to top |
|
|
|