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