gpt4 book ai didi

mysql - 从表中选择所有重复项

转载 作者:太空宇宙 更新时间:2023-11-03 12:32:07 24 4
gpt4 key购买 nike

我有一个包含这样列的表格:

serial_id   season  ep_id
1 1 1 < duplicate
1 1 2
3 1 1
...
1 1 1 < duplicate

我想选择在 serial_id、season 和 ep_id 中具有重复值的所有行,我应该使用什么查询?谢谢。

最佳答案

“..serial_id、season 和 ep_id 中的重复值。”

SELECT  serial_id, ep_id, season
FROM tableName
GROUP BY serial_id, ep_id, season
HAVING COUNT(*) > 1

但是如果你想获取行内的所有列(*假设你有除 serial_id、ep_id、season 之外的其他列*)

SELECT  a.*
FROM tableName a
INNER JOIN
(
SELECT serial_id, ep_id, season
FROM tableName
GROUP BY serial_id, ep_id, season
HAVING COUNT(*) > 1
) b ON a.serial_id = b.serial_id AND
a.ep_id = b.ep_id AND
a.season = b.season

关于mysql - 从表中选择所有重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14922016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com