Re: Select duplicate data from a table

From: J.O. Aho <user_at_example.net>
Date: Fri, 23 Mar 2018 23:18:38 +0100
Message-ID: <fhlcpvFejg4U1_at_mid.individual.net>


On 03/23/18 17:55, Boubaker Idir wrote:
> Hello guys, I can't find the right mysql request to select duplicate data for my case:
> I have a table "myTable" and I have this data: packetid, bssid, rssi
> One packetid have more than one bssid and more than one rssi.
>
> I want to select all packetids without the packetids that have more than 3 similar bssid, similar bssid between the packetids.
>
> packetid1 = bssid1,bssid2,bssid3,bssid4
> packetid2 = bssid2,bssid3,bssid4 ====> eliminate this packetid from selection
> Packetid3 = bssid1,bssid2 ====> eliminate this packetid
> packetid4 = bssid1,bssid2,bssid4 ====> eliminate this packetid
> packetid5 = bssid1,bssid2,bssid5 ====> save this packetid to selection

If there can't be duplicate bssid (assuming rssi is null while bssid is set, I know that this would be a bad database design)

select packetid from myTable where rssi is null group by packetid having count(bssid) > 3

If you can have duplicate of one bssid value for a packetid, then select distinct first and from that then have the select based on group by and using the having to select the ones with more than three bssid.

-- 

 //Aho
Received on Fri Mar 23 2018 - 23:18:38 CET

Original text of this message