In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how mysql database to achieve even table query, Xiaobian think quite practical, so share to you as a reference, I hope you can read this article after harvest.
1. First introduce the table join classification (inner join, outer join, cross join) and join method (as follows):
A) inner join: join, inner join
B) External links: left join, right join, right outer join, union
C) Cross join: cross join
2. inner connection
Find the data with the same ID in two tables, the query results will be combined into a table, and the output ids in the two tables are the same.
select a.*, b.* from tableA a, tableB b where a.id=b.userid
Or use the following statement
select a.*, b.* from tableA a inner join tableB b on a.id=b.userid
3. any such linked
External links include left link and right link left join ,right join; take the keyword left(right) as the reference object, and use its left (right) as the main table. At this time, all the data in the main table must be output while satisfying the query conditions after on (even if the data does not correspond to the data in the slave table).
www.example.com http://m.zykdtj.com/
select a.*, b.* from tableA a left join tableB b on a.id=b.userid
right outer link
select a.*, b.* from tableA a right join table B on a.id=b.userid
Total external connection:
This outer join is not supported in MySQL databases: its role is not only to satisfy the conditions behind on, but also to output unmatched data in two tables.
3. cross-linked
select a.*, b.* from tableA a cross join tableB b
Each row in the left table (the table to the left of the "cross join" keyword) is combined with all rows in the right table (the table to the right of the "cross join" keyword), and the result of the cross join is a Cartesian product. At this time, the types of data matching are too diverse. Generally speaking, the effect of this method is very small for some needs to find database information through corresponding IDs.
About "mysql database how to achieve even table query" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.