Get the App
SLTechnology News&Howtos  ›  Database  › 

How does mysql implement table join (including left, right, inner, full join)

Shulou Source: shulou.com Published: 2022-06-01 21:46:03 10月03日 Update

Mysql how to achieve table join (including left, right, inner, full join), first of all need to appear in the query of the join of two tables, the following examples to explain the differences between various join queries.

Table an and table b are shown below

Table a contains abcd

There is abcf in table b

Internal connection:

SELECT * from an INNER JOIN b on a.name=b.id

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

Left connection:

SELECT * from a left JOIN b on a.name=b.id

The query result is shown in the figure, and table an is selected as the benchmark. (abcd)

Right connection:

SELECT * from a right JOIN b on a.name=b.id

The query result is shown in the figure, and table an is selected as the benchmark. (abcf)

Full connection: mysql does not support full connection (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)

The result is that all are displayed, as shown in the following figure:

These are the details about how mysql implements table joins (including left, right, inner, and full joins). If you want to know more, please follow other related articles!

Tags: Results full connection query such as figure selection content benchmark different two examples that is articles more support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information OPPO Reno Redmi Docker