首先很抱歉,如果标题令人困惑,很难在一行中解释!
好的,所以我正在创建一个脚本来提醒我数据库中任何可能存在的重复行。SELECT events.date, events.ven_id, COUNT(*)
FROM events
GROUP BY events.date, events.ven_id
HAVING COUNT(*) > 1
这成功找到重复的行,但只返回date
和ven_id
列,id就像以某种方式在select语句中获取events.*
,但仍然只返回重复的行。
这可能吗?
答案 0 :(得分:0)
SELECT events.date, events.ven_id, (select COUNT(*) events where date = ev.date and ven_id=ev.id) as eventcount
FROM events ev
GROUP BY events.date, events.ven_id
where eventcount > 1