473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

The real difference between LEFT and RIGHT JOINS

Hi,

What is the real difference between LEFT JOIN and RIGHT JOIN?
Are there situations where a query with RIGHT JOIN cannot
be rewritten with LEFT JOIN and tables reversed? (and vice versa).

In MySQL documentation there is stated explicitly:
"RIGHT JOIN is implemented analogously to LEFT JOIN, with the roles of
the tables reversed."

So may be it would be enough to have one universal LEFTRIGHT join
and put tables in a query in proper places depending on what
results are needed? What are two different JOIN syntaxes for?

Thank you in advance.

Marek Kotowski
Warsaw
Jul 23 '05 #1
4 8157
Marek Kotowski wrote:
Hi,

What is the real difference between LEFT JOIN and RIGHT JOIN?
Are there situations where a query with RIGHT JOIN cannot
be rewritten with LEFT JOIN and tables reversed? (and vice versa).

In MySQL documentation there is stated explicitly:
"RIGHT JOIN is implemented analogously to LEFT JOIN, with the roles of
the tables reversed."

So may be it would be enough to have one universal LEFTRIGHT join
and put tables in a query in proper places depending on what
results are needed? What are two different JOIN syntaxes for?

Thank you in advance.

Marek Kotowski
Warsaw


What would a LEFTRIGHT OUTER JOIN do?

Aside from that the order in which tables are specified in the
FROM should have no bearing on the performance of the query
since optimizers select the order of the tables based on
statistical analysis rather than specification order.

Jerry
Jul 23 '05 #2
Marek Kotowski wrote:
So may be it would be enough to have one universal LEFTRIGHT join
and put tables in a query in proper places depending on what
results are needed?
Yes, there is such a thing. It is spelled "LEFT JOIN". Just list the
tables in the specific order, based on which result you want.

Or if it's easier for your editor to overwrite a word, instead of cut
and paste table names to reverse their order, change "LEFT" to "RIGHT".
What are two different JOIN syntaxes for?


Keep in mind that the SQL-92 language was designed by a committee. ;-)

Regards,
Bill K.
Jul 23 '05 #3
Bill Karwin <bi**@karwin.com> wrote in message news:<d3*********@enews2.newsguy.com>...
What are two different JOIN syntaxes for?


Keep in mind that the SQL-92 language was designed by a committee. ;-)

Regards,
Bill K.


Thank you. So I see (am I right?) that - to say the truth -
enough would be always to use LEFT JOIN and just
to manipulate tables. This way one can always get results
he needs. No real functionality lost.

Regards

Marek Kotowski
Warsaw
Jul 23 '05 #4
Perhaps it's an accomodation for left-handed programmers.

Marek Kotowski wrote:
Bill Karwin <bi**@karwin.com> wrote in message news:<d3*********@enews2.newsguy.com>...
What are two different JOIN syntaxes for?


Keep in mind that the SQL-92 language was designed by a committee. ;-)

Regards,
Bill K.

Thank you. So I see (am I right?) that - to say the truth -
enough would be always to use LEFT JOIN and just
to manipulate tables. This way one can always get results
he needs. No real functionality lost.

Regards

Marek Kotowski
Warsaw


Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
49
by: Mike MacSween | last post by:
I frequently hear that there isn't a commercially available dbms that fully implements the relational model. Why not? And which product comes closest. Mike MacSween
2
by: tricard | last post by:
Good day all, I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since...
1
by: Eitan M | last post by:
Hello, I want to do select like this : select t1.col_2 from table_1 t1, table_2 t2 where t1.col_1 = t2.col_1 (+) The above is correct syntax for Oracle. What is the correct syntax for...
4
by: Jane T | last post by:
I appreciate how difficult it is to resolve a problem without all the information but maybe someone has come across a similar problem. I have an 'extract' table which has 1853 rows when I ask for...
1
by: nico3334 | last post by:
I have a query that currently pulls data from a main table and a second table using LEFT OUTER JOIN. I know how to do make another LEFT OUTER JOIN with the main table, but I want to add another LEFT...
9
by: shapper | last post by:
Hello, I am used to SQL but I am starting to use LINQ. How can I create Left, Right and Inner joins in LINQ? How to distinguish the different joins? Here is a great SQL example:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.