Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize join query on MYSQL multiple tables

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report