I was afraid to test out Dean's (since he hadn't yet)... and I didn't understand his coding commands (guess I'm still a php newbie of sorts). So, I wrote my own version which should do the same thing.
Somehow, over the 6 years or so of using ListMail, I've added lists together and inadvertently created over 83,000 duplicates. This script cleaned them all out, and left just one of each email subscriber... all in under 5mins.
Best of all, you'll notice the MIN(cnf) command within the mysql statement - it keeps the lowest cnf out of the set of duplicates... Essentially, if there's one that's been removed (cnf=2) and one that's still active (cnf=1), it keeps the active one. (NOTE: I don't use "unconfirmed" on this: cnf=0. Careful if you do!) Anyways, here it is, just wanted to share:
<?phpinclude('./config.php');include('./admin.php');// list to de-dupe$list = '2';$rows = mysql_query("SELECT id,email,MIN(cnf) FROM lm_users WHERE list = '$list' GROUP BY email");while($row = mysql_fetch_array($rows)) { $query2 = "SELECT id,email FROM lm_users WHERE list = '$list' AND email = '".$row['email']."'"; $rows2 = mysql_query($query2); $num2 = mysql_num_rows($rows2); if ($num2 > 1) { $query3 = "DELETE FROM lm_users WHERE id <> '".$row['id']."' AND list = '$list' AND email = '".$row['email']."'"; mysql_query($query3); echo $row['email']." duplicate removed.<BR>"; $c++; }}echo $c;?>