MySQL left join joins right

Source: Internet
Author: User

CreateTable Java (namevarchar255));Insertinto JavaVALUES (‘Java1‘),(‘Java2‘),(‘Blue‘);CreateTable MySQL (namevarchar255));Insertinto MySQLVALUES (‘Mysql1‘),(‘Mysql2‘),(‘Blue‘);

1.join Query inline query Check two tables to contact the same value

SELECT * from Java join MySQL as my< Span style= "color: #ff0000;" >< Span style= "color: #ff0000;" > My.name = Java.name;

+------+------+
| name | name |
+------+------+
| Blue | Blue |
+------+------+
1 row in Set (0.00 sec) Query Results

2.left join Query the left table of the main table is the information of the left table all will find out the information of the right table is only relevant to find out the remaining query results are null efficiency slower

SELECT * from Java left joins MySQL as my on java.name=my.name;


+-------+------+
| name | name |
+-------+------+
| JAVA1 | NULL |
| Java2 | NULL |
| Blue | Blue |
+-------+------+
3 Rows in Set (0.00 sec) Query Results

3.rignt join is exactly the opposite of the left join






MySQL left join joins right

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.