Home > Database > Mysql Tutorial > About mysql implementation of table join (left, right, inner, full join)

About mysql implementation of table join (left, right, inner, full join)

藏色散人
Release: 2020-03-20 09:02:01
forward
2410 people have browsed it

mysql implements table connection (left, right, inner, full join)

The connection between two tables appears in the query. The following uses examples to explain the differences between various connection queries

Table a, and table b are as shown below

a has abcd in the table

About mysql implementation of table join (left, right, inner, full join)

## b has abcf

in the table About mysql implementation of table join (left, right, inner, full join)

Inner join:

SELECT * from a INNER JOIN b on a.name=b.id;
Copy after login

The result is as shown in the figure, select the equivalent result (abc)

About mysql implementation of table join (left, right, inner, full join)

Left join:

SELECT * from a left JOIN b on a.name=b.id;
Copy after login

The query results are as shown in the figure, select table a as the benchmark. (abcd)

About mysql implementation of table join (left, right, inner, full join)

Right join:

SELECT * from a right JOIN b on a.name=b.id;
Copy after login

The query results are as shown in the figure, select table a as the benchmark. (abcf)

About mysql implementation of table join (left, right, inner, full join)

Full join: mysql does not support full join (full join), you can use left join union right join

(SELECT  * from a left JOIN b on a.name=b.id) UNION   (SELECT  * from a RIGHT JOIN b on a.name=b.id );
Copy after login

The result is that all are displayed , as shown below:

About mysql implementation of table join (left, right, inner, full join)

Recommended mysql video tutorial, address:

https://www.php.cn/course/list/51.html

The above is the detailed content of About mysql implementation of table join (left, right, inner, full join). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template