Firstly sorry if the title is confusing, difficult to explain in one line!
ok, so i'm making a script to alert me of any po开发者_JAVA技巧tential duplicate rows in my db.
SELECT events.date, events.ven_id, COUNT(*)
FROM events
GROUP BY events.date, events.ven_id
HAVING COUNT(*) > 1
this successfully finds duplicate row, however only returns the date
and ven_id
columns, id like to get an events.*
into the select statement somehow but still only return duplicate rows.
is this possible?
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
精彩评论