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

Multi-table query of MYSQL

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Cartesian product select * from emp,dep; select * from emp,dep where emp.dep_id = dep.id;select * from emp,dep where emp.dep_id = dep.id and dep.name = "technology"; 2. Inner join: only take records select * from emp inner join dep on emp.dep_id = dep.id that have corresponding relations between two tables Select * from emp inner join dep on emp.dep_id = dep.id where dep.name = "technology"; inner join join two tables, where filter condition, only take the conditions meet 3. Left join: keep the record select * from emp left join dep on emp.dep_id = dep.id without corresponding relationship in the left table on the basis of inner join 4. Right join: keep records with no corresponding relationship in the right table select * from emp right join dep on emp.dep_id = dep.id;5, full join: keep records with no corresponding relationship in the left and right tables on the basis of internal connection: select * from emp left join dep on emp.dep_id = dep.idunionselect * from emp right join dep on emp.dep_id = dep.id

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

Wechat

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

12
Report