MySQL Learning record One

Source: Internet
Author: User

1.MySQL JOIN operation

The left join is based on left table and its records are all represented, while the right table shows only the records that meet the search criteria. The right join is based on the table on the left, and its records are all displayed, and only records that meet the search criteria are displayed in the table. The following first creates two tables for testing, table A contains the ID (AID) and the name (AName), and table B contains the ID (BID) and the study number (Bnum).

Figure 1

As you can see, the table was created successfully and several data were inserted. The following test begins with the left and right connections, as shown in result 2.

Figure 2

As can be seen from Figure 2, the left connection is based on table A, a total of 5 records. In the results, table B displays only records with A.aid = B.bid, and unequal places are filled with null. The right connection, based on table B, a total of 4 records. In the result, table A shows only the records that meet the search criteria, and the others are filled with null.

Below, test the inner JOIN operation. An inner join expression means an equal connection, on which the search condition is expressed. Results with no search criteria are shown in result 3 with on.

Figure 3

When using the JOIN operation, note that the on condition requires attention to some things. The difference between the and condition control and where control is shown in 4.

MySQL Learning record One

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.