开发者

Mysql : can select dupes ok, how do i select the other data at same time?

开发者 https://www.devze.com 2023-01-16 03:03 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消