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 > Database Server Software > MySQL > Does MySQL has 'FULL JOIN' feature?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-04, 09:23
Bhargav Bhargav is offline
Registered User
 
Join Date: Apr 2004
Posts: 15
Does MySQL has 'FULL JOIN' feature?

Hello,
I need to know whether MySQL supports 'FULL JOIN' or not. If so,
and if you also know which version, that would be a great help.

Thanks
Bhargav
Reply With Quote
  #2 (permalink)  
Old 05-25-04, 10:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
nope

but you can get the same results by using LEFT OUTER UNION RIGHT OUTER
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-02-04, 09:19
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Won't using LEFT OUTER UNION RIGHT OUTER duplicate the rows that actually do join successfully? I think that you'd need to qualify one of them to get only the non-matches.

-PatP
Reply With Quote
  #4 (permalink)  
Old 06-02-04, 09:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
pat, pat, pat

take a deep breath

UNION removes dupes
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 06-02-04, 09:30
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
using UNION ALL and qualifying one of them may or may not result in better execution

SELECT ... FROM a LEFT OUTER JOIN b ON a.x = b.y
UNION ALL
SELECT ... FROM a RIGHT OUTER JOIN b ON a.x = b.y WHERE a.x IS NULL

it all depends on whether forcing the optimizer to examine the nullity of the join column is faster than letting it realize there may be dupes and dropping them during the merge
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 06-02-04, 09:35
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Quote:
Originally Posted by r937
UNION removes dupes
Yeah, but that is a bad thing if the underlying data is supposed to contain dupes, right?

-PatP
Reply With Quote
  #7 (permalink)  
Old 06-02-04, 09:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
"supposed to contain dupes" ????

pat, allow me to introduce you to the concept of "if it ain't got a PK it ain't a table"

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 06-02-04, 12:07
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Quote:
Originally Posted by r937
"supposed to contain dupes" ????

pat, allow me to introduce you to the concept of "if it ain't got a PK it ain't a table"

Yeah, but ain't that what MySQL is for??? Data what ain't really relational?

I agree with you wholeheartedly, that containing duplicates shouldn't be a concern, but when I'm doing "rescues" of MySQL databases they are frequently chock full of things that make relational purists like you and I shudder!

If Bhargav posted something about a PK that I missed, I'm sorry. Since I don't remember having seen anything about a PK, I didn't assume that one was there.

-PatP
Reply With Quote
  #9 (permalink)  
Old 06-02-04, 12:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by Pat Phelan
Since I don't remember having seen anything about a PK, I didn't assume that one was there.
i understand fully where you're coming from, as i came from there myself

however, things are a lot simpler when you explain things in accordance with relational theory first, and then handle the exceptions afterwards

(however, it is wise not to mention the relational theory in the answer, because people usually don't want to digest relational theory at the same time as they are solving an elementary problem)

for example, if the poster comes back with "aack! LEFT OUTER UNION RIGHT OUTER has dropped some important rows!" then i can address that problem, but not before
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #10 (permalink)  
Old 06-02-04, 14:57
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
As long as that works for you, I'm good with it! I guess I just take a different philosophical approach, but as long as your way works for you and mine works for me, then we're both "good to go" on things!

-PatP
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