Get the App
SLTechnology News&Howtos  ›  Database  › 

How to realize join query on MYSQL multiple tables

Shulou Source: shulou.com Published: 2022-06-01 19:09:31 10月04日 Update

The following together to understand how to achieve the MYSQL multi-table join query, I believe you will benefit a lot after reading, the text is not in the essence, hope that how to achieve the MYSQL multi-table join query this short content is what you want.

The difference between the three connection methods:

INNER JOIN (inner join, or equivalent join): gets the record of the matching relationship between the fields in two tables.

LEFT JOIN (left join): gets all the records in the left table, even if there are no matching records in the right table.

RIGHT JOIN (right join): contrary to LEFT JOIN, it is used to get all the records in the right table, even if there is no corresponding matching record in the left table.

3 table join queries with the following statements:

SELECT a.YHID FROM a.TDID LEFT JOIN km_tdxx b.YHMC ON a.YHID=b.YHID b.YHZH LEFT JOIN km_tdxx c ON a.TDID=c.TDID

Km_tdcy: team membership table (record which team those people belong to)

Km_xtyh: system user tabl

Km_tdxx: team information table

Interpretation: the first two tables are connected and queried, and the people with the team are found first. Connect with table c from the results of an and b to find out the team name of the person who has a team.

In addition, there are the following query methods:

-

Add IS NULL or IS NOT NULL conditions to filter out another table.

-

The full join query queries all the data of tables An and B. if there are NULL conditions in the WHERE keyword, you can filter out the relevant data of tables An and B.

After reading this article on how to implement join query on MYSQL multi-tables, many readers will want to know more about it. If you need more industry information, you can follow our industry information section.

Tags: Query team two people information content data method more condition industry affirmation benefit greatly all connection key keyword name field member text Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Shulou Information Huawei Microsoft