Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

why right outer join is needed?

 
   Database Forums (Home) -> Programming RSS
Next:  Whitepaper - Spreadsheet reporting within a BI fr..  
Author Message
Archana

External


Since: Jun 02, 2008
Posts: 5



(Msg. 1) Posted: Mon Jul 12, 2010 1:59 am
Post subject: why right outer join is needed?
Archived from groups: microsoft>public>sqlserver>programming (more info?)

hello,

i am having one query regarding joins

if in left join i reverse order of table it behaves like right join
then why we need to seperate joins?

thanks in advance.

 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
Dan

External


Since: May 18, 2010
Posts: 5



(Msg. 2) Posted: Mon Jul 12, 2010 5:25 am
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Archana" wrote in message

> hello,
>
> i am having one query regarding joins
>
> if in left join i reverse order of table it behaves like right join
> then why we need to seperate joins?
>
> thanks in advance.

For ease of writing queries - sometimes it's easier to use a right join for
readability rather than swapping things around to use a left join.

--
Dan

 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
--CELKO--

External


Since: Apr 17, 2007
Posts: 417



(Msg. 3) Posted: Mon Jul 12, 2010 11:46 am
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>> if in left join i reverse order of table it behaves like right join then why we need to separate joins? <<

Historical reasons. When we voted on this in ANSI X2H2, the proposal
included a whole list of in-fixed joins, most of them redundant and
not implemented. BUT they were easy to define once we had the
definition of an outer join. Here is the BNF

<joined table> ::=
<cross join> | <qualified join> | (<joined table>)

<cross join> ::= <table reference> CROSS JOIN <table reference>

<qualified join> ::=
<table reference> [NATURAL] [<join type>] JOIN
<table reference> [<join specification>]

<join specification> ::= <join condition> | <named columns join>

<join condition> ::= ON <search condition>

<named columns join> ::= USING (<join column list>)

<join type> ::= INNER | <outer join type> [OUTER] | UNION

<outer join type> ::= LEFT | RIGHT | FULL

<join column list> ::= <column name list>

<table reference> ::=
<table name> [[AS] <correlation name>[(<derived column
list>)]]
| <derived table>
[AS] <correlation name> [(<derived column list>)]
| <joined table>

<derived table> ::= <table subquery>

<column name list> ::=
<column name> [{ <comma> <column name> }...]
 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 1649



(Msg. 4) Posted: Mon Jul 12, 2010 5:25 pm
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Archana ( ) writes:
> i am having one query regarding joins
>
> if in left join i reverse order of table it behaves like right join
> then why we need to seperate joins?

Well, we don't. Personally, I never use RIGHT JOIN, and my head hurts
when I see code that does.


--
Erland Sommarskog, SQL Server MVP, esquel RemoveThis @sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
--CELKO--

External


Since: Apr 17, 2007
Posts: 417



(Msg. 5) Posted: Tue Jul 13, 2010 8:48 am
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>> Well, we don't. Personally, I never use RIGHT JOIN, and my head hurts when I see code that does. <<

LOL! Have you talked to an Arab or Chinese programmer? We Latin/Greek/
Cyrillic alphabet users have a very strong "left-to-right" mindset.

And, yes, I also freak out and re-arrange RIGHT OUTER JOINs in code I
have to maintain.
 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
Eric Isaacs

External


Since: May 12, 2008
Posts: 109



(Msg. 6) Posted: Tue Jul 13, 2010 12:56 pm
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It's not so much the left to right mindset as it is the top to bottom
mindset that makes the left join easier to read. If you format your
SQL so that each table is on it's own line in the FROM clause, then
the ones listed at the top are base tables and the ones on the bottom
are LEFT JOIN tables. That's why the LEFT JOIN is superior and easier
to read.

Consistency is more important, however. Bottoms up to anyone who
prefers RIGHT JOINS. Surprised)

-Eric Isaacs
 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
--CELKO--

External


Since: Apr 17, 2007
Posts: 417



(Msg. 7) Posted: Tue Jul 13, 2010 2:47 pm
Post subject: Re: why right outer join is needed? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>> It's not so much the left to right mindset as it is the top to bottom mindset that makes the left join easier to read. <<

Ever seen Chinese books? Classically, the characters go from top to
bottom in a column, then the columns go from right to left. It is a
very easy format if you are reading a scroll that you turn with the
right hand.

Likewise, speech balloons in Chinese manga are on the sides of the
panels. Computer game programs put the user messages on the right side
of the screen in a vertical column, etc.

Composition paper has separate vertical columns of blue line boxes for
characters, with the columns numbered from right to left. Their
version of our elementary school horizontal blue line paper!

My observation from teaching SQL for a few decades now is that Hebrew,
Arabic and Chinese native readers will write more RIGHT OUTER JOINS
than use Latin/Greek Cyrillic native readers.

But then Engineers write on quadrille paper. What does that say about
them? Smile
 >> Stay informed about: why right outer join is needed? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Outer join question - I have three tables: 1 - people 2 - peopleAddressLinkingTable 3 - Addresses I want to get all people and their street name. I thought that this would be simple and thought that the following query should work: select * from people, addresses.street..

Left Outer Join and Where Clause - Hi, I have two tables Table1 and Table2. I need to join Table2 on Table1_SID to get name for SID Column of Table1. But I need all rows of Table1. I can use a Left Outer Join to achieve this. Now I have a problem. There are rows in table2 and table1....

3 tables left outer join - I have 3 tables and would like to have all data exists on table 1 even does not exist in table 2 and tbale 3 are there any way to have left outer join for 3 tables or I have to use 2 quries to complete? Your information is great appreciated, Here is..

Problem with sorting in Full Outer Join table - Hello, I stucked on strange problem with data order in dataset. Any clue or suggests will be appreciated. Let's start from the beggining. We have to tables: Table1: Import Nr 18 19 20 21 22 23 24 25 26 27 28 29 32 33 34 Table2: Import Nr 20 21 23 25 26...

join then filter or filter the join design question. - Hi I have a pivot table that has about 3 million records. I need to do a cross join with another table that has about 10 columns. so roughly, I will have 30 million records to filter. the situation I have is I have to use this table 2 times to extract..
   Database Forums (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]