MySQL仅选择冗余行,而忽略原始行 [英] MySQL Select only the redundant rows and leave out the original rows
本文介绍了MySQL仅选择冗余行,而忽略原始行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这张桌子
ID | NAME | TICKETNO
---------------------
1 | Issa | K1
2 | kassim | K1
3 | Said | G5
4 | Maya | G5
5 | Sara | G5
6 | Kesi | J8
7 | Ima | J8
8 | Fali | O9
我想执行一个MySQL查询,以仅选择基于列TICKETNO
的重复项,而忽略原始行并生成如下表
And I want to perform an MySQL query to select only the duplicates based on the colum TICKETNO
and leave out the original rows and produce a table as follows
ID | NAME | TICKETNO
---------------------
2 | kassim | K1
4 | Maya | G5
5 | Sara | G5
7 | Ima | J8
有人可以通过MySQL查询实现这一目标吗?
Can someone give a MySQL query to achieve this?
推荐答案
您可以使用以下解决方案:
You can use the following solution:
SELECT * FROM table_name WHERE NOT ID IN (
SELECT MIN(ID) FROM table_name GROUP BY TICKETNO
)
这篇关于MySQL仅选择冗余行,而忽略原始行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文