Differences between inner join and where

Source: Internet
Author: User

1. Connection statements used in the WHERE clause are called implicit connections in the database language. Inner join ...... The connection generated by the on clause is called an explicit connection. (Other join parameters are also explicit connections.) There is no essential difference between the connection relationship between where and inner join, and the result is the same. But! Recessive connections have been gradually eliminated with the standardization and development of the database language, and the new database language has basically abandoned recessive connections, all of which adopt explicit connections.

2. Join clauses can be used no matter how they are connected. When connecting to the same table, be sure to define aliases. Otherwise, an error is returned!

A> Inner join: It is understood as "valid join". Only the data in both tables shows left join: It is understood as "with left display", for example, on. field = B. field to display all the data in Table A and all the data in Table A \ B. data in Table A and in Table B is displayed as null.

B> right join: it is interpreted as "right display", for example, on. field = B. field, all data in Table B and data in a \ B are displayed. data in Table B and in Table A is displayed as null.

C> full join: it is interpreted as "Full join". All data in the two tables is displayed, which is actually inner + (left-inner) + (right-inner)

3. Join can be divided into three types: Full outer join, left join, and right join.
Full outer join contains all records of the two tables.
The left join is based on the table on the left, supplemented by the right join, and the right join is opposite.

4. The following principles should be followed to Improve the Performance of database query statements:

  • When performing table-to-table connection queries, the large table is in front of the small table
  • Table aliases are not used. Fields in different tables are distinguished by field prefixes.
  • The restrictions in the query conditions should be written before the table connection conditions.
  • Use indexed fields as the query condition whenever possible

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.