dbTalk Databases Forums  

rewriting LEFT JOINs as RIGHT JOINs

comp.databases comp.databases


Discuss rewriting LEFT JOINs as RIGHT JOINs in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
yawnmoth
 
Posts: n/a

Default rewriting LEFT JOINs as RIGHT JOINs - 04-19-2008 , 09:10 AM






Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...

Reply With Quote
  #2  
Old   
Harry Skelton
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-19-2008 , 11:03 AM






yawnmoth wrote:
Quote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...
LEFT and RIGHT joins dictate precedence of the tables/queries. You
could do it either way, but what data you get back will be different.
If you do as you say, it is not merely changing the LEFT to a RIGHT, you
are changing the entire SQL query. This can cause unforeseen problems,
particularly speed, temp disk space consumed (some databases are not
smart on data retrieval and caching), and what records are actually
returned.

Thats like saying you can omit the ORs and ANDs and rewrite the SQL as a
SELECT/UNION query. It is not a simple thing and it wastes man hours
and computer time.


Reply With Quote
  #3  
Old   
Harry Skelton
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-19-2008 , 11:03 AM



yawnmoth wrote:
Quote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...
LEFT and RIGHT joins dictate precedence of the tables/queries. You
could do it either way, but what data you get back will be different.
If you do as you say, it is not merely changing the LEFT to a RIGHT, you
are changing the entire SQL query. This can cause unforeseen problems,
particularly speed, temp disk space consumed (some databases are not
smart on data retrieval and caching), and what records are actually
returned.

Thats like saying you can omit the ORs and ANDs and rewrite the SQL as a
SELECT/UNION query. It is not a simple thing and it wastes man hours
and computer time.


Reply With Quote
  #4  
Old   
Harry Skelton
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-19-2008 , 11:03 AM



yawnmoth wrote:
Quote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...
LEFT and RIGHT joins dictate precedence of the tables/queries. You
could do it either way, but what data you get back will be different.
If you do as you say, it is not merely changing the LEFT to a RIGHT, you
are changing the entire SQL query. This can cause unforeseen problems,
particularly speed, temp disk space consumed (some databases are not
smart on data retrieval and caching), and what records are actually
returned.

Thats like saying you can omit the ORs and ANDs and rewrite the SQL as a
SELECT/UNION query. It is not a simple thing and it wastes man hours
and computer time.


Reply With Quote
  #5  
Old   
--CELKO--
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-22-2008 , 03:13 PM



Quote:
can every LEFT JOIN be rewritten as a query with RIGHT JOINs?
Sure. Just put the preserved table expression on the RIGHT or LEFT
side of the infixed join operator and leave the ON clause alone. But
since you come from a culture that reads left to right, RIGHT OUTER
JOIN is harder to maintain or to even read.


Reply With Quote
  #6  
Old   
--CELKO--
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-22-2008 , 03:13 PM



Quote:
can every LEFT JOIN be rewritten as a query with RIGHT JOINs?
Sure. Just put the preserved table expression on the RIGHT or LEFT
side of the infixed join operator and leave the ON clause alone. But
since you come from a culture that reads left to right, RIGHT OUTER
JOIN is harder to maintain or to even read.


Reply With Quote
  #7  
Old   
--CELKO--
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-22-2008 , 03:13 PM



Quote:
can every LEFT JOIN be rewritten as a query with RIGHT JOINs?
Sure. Just put the preserved table expression on the RIGHT or LEFT
side of the infixed join operator and leave the ON clause alone. But
since you come from a culture that reads left to right, RIGHT OUTER
JOIN is harder to maintain or to even read.


Reply With Quote
  #8  
Old   
Roy Hann
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-24-2008 , 06:02 AM



"Harry Skelton" <skelton.harry (AT) gmail (DOT) com> wrote

Quote:
yawnmoth wrote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...

LEFT and RIGHT joins dictate precedence of the tables/queries. You could
do it either way, but what data you get back will be different. If you do
as you say, it is not merely changing the LEFT to a RIGHT, you are
changing the entire SQL query. This can cause unforeseen problems, [...]
are actually returned.
Total nonsense.

R.




Reply With Quote
  #9  
Old   
Roy Hann
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-24-2008 , 06:02 AM



"Harry Skelton" <skelton.harry (AT) gmail (DOT) com> wrote

Quote:
yawnmoth wrote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...

LEFT and RIGHT joins dictate precedence of the tables/queries. You could
do it either way, but what data you get back will be different. If you do
as you say, it is not merely changing the LEFT to a RIGHT, you are
changing the entire SQL query. This can cause unforeseen problems, [...]
are actually returned.
Total nonsense.

R.




Reply With Quote
  #10  
Old   
Roy Hann
 
Posts: n/a

Default Re: rewriting LEFT JOINs as RIGHT JOINs - 04-24-2008 , 06:02 AM



"Harry Skelton" <skelton.harry (AT) gmail (DOT) com> wrote

Quote:
yawnmoth wrote:
Out of curiosity, can every LEFT JOIN be rewritten as a query with
RIGHT JOINs? It seems to me that if you just take the "leftmost"
table and use that in the FROM part of a SELECT that all subsequent
LEFT JOINs would need to be RIGHT JOINs...

LEFT and RIGHT joins dictate precedence of the tables/queries. You could
do it either way, but what data you get back will be different. If you do
as you say, it is not merely changing the LEFT to a RIGHT, you are
changing the entire SQL query. This can cause unforeseen problems, [...]
are actually returned.
Total nonsense.

R.




Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.