SQL 选择具有(部分)重复数据的行
我有以下数据库模式:
Product ID | Component | ...
产品 ID - 外键
组件 - 产品的一部分
由于某些神秘的原因,许多记录具有相同的产品 ID 和产品 ID。成分。是否有一个 SQL 查询可以返回所有产品 ID 和产品 ID?具有多个相同组件的组件?
例如,给出下表
| Product ID | Component |
--------------------------
| 1 | c1000 |
| 1 | c1100 |
| 2 | c2000 |
| 2 | c2000 |
| 2 | c2200 |
| 3 | c3000 |
SQL 查询应返回:
| Product ID | Component |
--------------------------
| 2 | c2000 |
I have the following database schema:
Product ID | Component | ...
Product ID - a foreign key
Component - parts of the Product
For some Arcane reason a number of Records have the same Product ID & Component. Is there a SQL query that would return all the Product ID's & Components, that have multiple identical Components?
E.g. given the following table
| Product ID | Component |
--------------------------
| 1 | c1000 |
| 1 | c1100 |
| 2 | c2000 |
| 2 | c2000 |
| 2 | c2200 |
| 3 | c3000 |
The SQL query should return:
| Product ID | Component |
--------------------------
| 2 | c2000 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这还将显示有多少重复条目。
This will also show you how many duplicate entries there are.