If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Full Outer join vs Cross join

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-05, 14:56
anandtx0 anandtx0 is offline
Registered User
 
Join Date: Sep 2005
Posts: 2
Full Outer join vs Cross join

Hello

Is there any difference between a full outer join and a cross join.
seems like irrespective of the join condition, a full outer join will fetch all rows (including corresponding nulls) thus being equivalent to a cross join.
Am I missing anything.

thanks
Anand
Reply With Quote
  #2 (permalink)  
Old 09-27-05, 15:07
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Yes, there is a definite difference between them. A cross join is a Cartesian join, for sets of A and B rows, you'll get a result of A * B rows. A full join will match all possible rows, meaning it will return AT MOST A + B rows. For large values of A and B, the difference can be huge.

Let me know what database engine you are using, and I'll cook up a short demo script if you'd like.

-PatP
Reply With Quote
  #3 (permalink)  
Old 09-27-05, 17:30
anandtx0 anandtx0 is offline
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks Pat for the clarification. I got it now.
Reply With Quote
  #4 (permalink)  
Old 03-06-09, 16:37
brandonvmoore brandonvmoore is offline
Registered User
 
Join Date: Mar 2009
Posts: 3
The above statement that an outer join will return A + B rows at max is making the assumption that there is a 1 to 1 relationship between table A and table B.

Any type of join will degrade to a cross join when the conditions are always true. Consider two tables with a column called "One" and every row of this column contains the number 1 for this field. You could do an inner join of these two tables on this field and the resulting number of rows would be A * B rather than A + B.
Reply With Quote
  #5 (permalink)  
Old 03-06-09, 17:35
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
There was a bit of "out of band" communication missing from this discussion. At the time of the original exchange, I was privvy to the detail that the columns that were used to FULL JOIN the two tables each had PK (Primary Key) constraints on them, so no duplicate values were allowed.

Brandon is correct in that any join on a unconstrained columns can decay into a CROSS JOIN. In this case, if the join column has value X (which is not NULL) for every row in both tables, there will then be A * B rows in the result set.

-PatP
Reply With Quote
  #6 (permalink)  
Old 03-07-09, 05:40
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
You can remember the background of posts from 3.5 years ago? I can barely remember posts from 3.5 hours ago
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #7 (permalink)  
Old 03-07-09, 09:44
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I'm weird.

-PatP
Reply With Quote
  #8 (permalink)  
Old 03-08-09, 04:09
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
phew. That was digging up threads from the dead...
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #9 (permalink)  
Old 03-08-09, 22:34
brandonvmoore brandonvmoore is offline
Registered User
 
Join Date: Mar 2009
Posts: 3
Wow

Wow Pat, I was about to comment on your ability to remember details of this thread from that long ago but it looks like someone else beat me to it. I almost didn't comment b/c I noticed the thread was so old, but then it occurred to me that it 'was' the first result Google returned to me so I figured others would probably see it too .
Reply With Quote
  #10 (permalink)  
Old 03-08-09, 22:39
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
We (or at least I) very, VERY rarely get thanks or even feedback for much of anything. That makes threads like these unique, which tends to make things stick in my mind.

I often wonder what the heck keeps me doing this (administering the forum) for nothing, but every once in a while you get a chance to make a real positive difference, and at least for me that makes it all worth while.

-PatP
Reply With Quote
  #11 (permalink)  
Old 03-08-09, 22:58
brandonvmoore brandonvmoore is offline
Registered User
 
Join Date: Mar 2009
Posts: 3
Well let me add my thanks to you as well then. Years ago I took an Access class (which was actually quite usefull since it was more about db normalization). Virtually everything else I know about databases (or VB, C#, ASP, XML, etc.) has come from reading whatever I could find on the internet and I'm certain I would not have gotten to where I am w/o people like yourself.
Reply With Quote
  #12 (permalink)  
Old 03-09-09, 04:09
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Quote:
Originally Posted by brandonvmoore
it occurred to me that it 'was' the first result Google returned to me so I figured others would probably see it too .
That is a jolly good point, and puts a whole new spin on what sometimes looks like pointless "thread resurrection".

We may be at peace - this thread has, after 3.5 years, finally fulfilled its destiny.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On