MySQL connection query

Source: Internet
Author: User
Tags aliases

Focus:

Left join is to find out the table 1 (the most left-most table in the statement), even if Table 2 (the most right table in the statement) does not match (with null display)

The right connection is to find out the table 2 (the most right table in the statement), even if Table 21 (the most left-most table in the statement) does not match (with null display).

Do not change the position of table 1, 2, as long as the left to right to the line (the connection is changed to a correct connection). Here the 1, 2 is a relative concept, 1 on the left, 2 on the right.

It is recommended to use aliases to write statements so that the results are clearer, the program is recognizable, and the new table names are added directly to the original table name.

1, inner connection (Cartesian product n*m)

2. External connection

Including the left and right connections, the left link to the left side of the table information is listed, even if the right side of the table does not match (with a null match);

The right connection lists the information on the right side of the table, even if the table on the left does not match it (with a null match).

3, LEFT JOIN connect

4. Right Connection

The right connection using aliases is more refreshing and the program readability is even higher.

5. Multi-condition Connection

There are multiple criteria for querying:

MySQL connection query

Related Article

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.