SQL connects multiple tables with commas which join?

Source: Internet
Author: User
Tags joins

Transferred from: http://blog.csdn.net/huanghanqian/article/details/52847835

The difference between the four joins is commonplace:

    • INNER join (can also be abbreviated as JOIN): Returns a row if there is at least one match in the table
    • Left JOIN: Returns all rows from the table, even if there is no match in the right table
    • Right JOIN: Returns all rows from the correct table even if there is no match in the left table
    • Full JOIN: Returns a row if there is a match in one of the tables

So the problem is, there is a common way to do this is to separate the table with commas, and how is this connected?

Look at these two tables first.

Use comma-separated methods to join tables:

* FROM     employee,employee.  Department.  DepartmentID       

Output Result:

It is obvious to me that this is not the INNER join!

Yes, the answer is this: SQL joins multiple tables with commas that correspond to inner joins.

For the sake of rigor, I looked everywhere for official SQL documents to confirm this. However, you can not find the SQL document (who knows the URL must be sent to me), and finally found on Wikipedia as an argument.

SQL defines two different syntax ways to represent "connections." The first is the explicit join symbol, which uses the keyword explicitly, followed by JOIN the implicit join symbol, which uses the so-called implicit join symbol. The implicit join symbol places the tables that need to be connected into the parts of the SELECT statement FROM , separated by commas. This makes up a "cross-join" where the WHERE statement may place some filter predicates (filtering conditions). Those filter predicates are functionally equivalent to explicit join symbols. The SQL 89 standard supports only internal and cross-joins, so there is only an implicit connection to this expression, and the SQL 92 standard adds support for external connections, which is the JOIN expression.

Other words

*from   employee        employee.  Department.  DepartmentID      

Equivalent to:

* FROM     employee,employee.  Department.  DepartmentID       

As to which efficiency is higher, actually the two are one thing, no difference. Only the inner connection is written in the SQL 1999 rule.

Also, when writing SQL statements to test 4 joins, it is found that MySQL returns the same results as the INNER join for full join. After consulting the data, only found that MySQL does not support full join AH.

See: Http://stackoverflow.com/questions/4796872/full-outer-join-in-mysql

Resources:

1. Wikipedia https://zh.wikipedia.org/wiki/%E8%BF%9E%E6%8E%A5_ (SQL)

2.w3school http://www.w3school.com.cn/sql/sql_join.asp

3.CSDN blog Last Words http://www.cnblogs.com/huangfr/archive/2012/06/20/2555530.html

SQL connects multiple tables with commas which join?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.