MySQL Learning (vi) MySQL connection

Source: Internet
Author: User

For MySQL internal connections, outer connections, cross connections

1. Internal connection : Combine the rows in two tables that meet the join criteria as a result set------inner

Syntax: Select column 1, column 2, column n from table one inner join table two on table one column = Table two column []where conditional statement]

eg

Table I (Qiche)

Table II (QICHE1)

SELECT * FROM Qiche inner join qiche1 on qiche.id=qiche1.id results are as follows:

2. External connection

A. Left connection (On the basis of the join, it also contains all the non-qualifying rows of data in the left table, and fills in the right table column with null)-----------

Syntax: Select column 1, column 2, column n from table one left join table two on table one column = table two columns

Eg:select * from Qiche left joins Qiche1 on Qiche. Brand =qiche1. Brand results are as follows:

B. Right connection (On the basis of the join, it also contains all the non-qualifying rows of data in the right table, and the left table column is filled with null)------------

Syntax: Select column 1, column 2, column n from table one right join table two on table one column = table two columns

C. Full outer join (on the basis of the inner joins, also contains all the non-qualifying data rows in the two tables, and the left table, and the right table column in which null is filled)-------full

But in fact MySQL does not support full-outer connections

3. Cross-connect (The thing to do is to regroup each row of data in one table and all the rows in another table to form a new data table, the number of data bars for the result: Left table row X right table row number
There is a concept called Cartesian product)-----------Cross Join

Syntax: SELECT * FROM Table a cross join Table II

Eg:select * The results from the Qiche cross join Qiche1 are as follows:

MySQL Learning (vi) MySQL connection

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.