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 find intersection in mysql

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Mysql how to seek intersection, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

In mysql, you can use the "SELECT" statement and the "INNER JOIN" keyword to query the intersection and find the intersection data. The syntax "SELECT field name FROM data Table 1 INNER JOIN data Table 2 USING (field name)".

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Create two tables

CREATE TABLE `object_ a` (`id` bigint (20) NOT NULL AUTO_INCREMENT, `oname` varchar (50) DEFAULT NULL, `otim` varchar (50) DEFAULT NULL, `create_ time` datetime DEFAULT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

Add data

CREATE TABLE `object_ b` (`id` bigint (20) NOT NULL AUTO_INCREMENT, `oname` varchar (50) DEFAULT NULL, `ofu` varchar (50) DEFAULT NULL, `create_ time` datetime DEFAULT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

Add data

Query intersection

SELECT a.oname,a.odesc FROM object_a an INNER JOIN object_b b ON a.oname=b.oname AND a.odesc=b.odesc

Equivalent to

SELECT a.oname.odesc FROM object_a an INNER JOIN object_b b USING (oname,odesc)

The results are as follows

PS: other databases can try this method.

After reading the above, SELECT oname,odesc FROM object_a INTERSECTSELECT oname,odesc FROM object_b, have you mastered how to find the intersection of mysql? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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