By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,028 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,028 IT Pros & Developers. It's quick & easy.

The real difference between LEFT and RIGHT JOINS

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.