MySQL uses connections for multi-table retrieval

Source: Internet
Author: User

1. Internal connection:

INNER join, Crross Join,join is an equivalent connection in MySQL that produces a Cartesian product.

The join operator "," (comma) is similar, but the precedence of the comma operator differs from the other connection types. Sometimes, when other connection types are normal, it causes syntax errors, so it is recommended to avoid using the comma operator as much as possible


Other syntax formats: Use the ON clause instead of the WHERE clause. Example: SELECT t1.*,t.* from t1 INNER JOIN t2 on t1.i1 = T2.i2

Use the using () clause. It is conceptually similar to the ON clause, but requires that the connected column must have the same name. The following query statement can connect the mytbl1.b to the mytbl2.b

SELECT mytbl1.*,mytbl2.* FORM mytbl1 INNER JOIN mytbl2 USING (b);

2. Left outer and right outer connections

The left OUTER join uses the right join

The left JOIN works by specifying the columns used to match the rows in the two table, and then, when a row in the right table of the left table row matches, the contents of the two rows are selected as an output line, and when a row of left table does not match in the right side,

It will still be selected as an output line, except that it is connected to a dummy row of the right table, where each column contains null.

It is important to note that there is no problem with the row in the result set of the right table, which is defined as NOT NULL. For example, if the right table contains a column with a value of NULL, you cannot distinguish these null values from those that identify unmatched rows.

MySQL uses connections for multi-table retrieval

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.