Author Topic: How do I combine two lists?  (Read 3545 times)

straxxus

  • Posts: 1
    • View Profile
How do I combine two lists?
« on: July 22, 2006, 06:24:35 pm »
Hi, I have two lists. I would like to combine them into one list.

What is the best way to combine the two lists?

-Michael

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
How do I combine two lists?
« Reply #1 on: July 23, 2006, 01:19:34 am »
At this time you must export the users from the source list and then re-import the users into another list.  I hope to provide checkboxes and "with selected" or "with entire list" options soon so that you might more easily move users.

Another option is using a custom command in PhpMyAdmin, but this runs the risk of duplicates on a list...

update lm_users set list = '2' where list = '1';

a quick PHP script you can upload to your ListMail folder to de-dupe a list (Warning: make a backup first as this is untested..):
Code: [Select]
<?phpinclude('./config.php');include('./admin.php');// list to de-dupe$list = '2';$rows = mysql_query("select id,email from lm_users where list = '$list';");while(list($id,$email)=mysql_fetch_row($rows)){ list($cnt)=mysql_fetch_row(mysql_query("select count(*) from lm_users where email like '$email' and id <> '$id' and list = '$list';")); if($cnt>0) mysql_query("delete from lm_users where id = '$id';");}?>

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

idealizm

  • Posts: 13
    • View Profile
How do I combine two lists?
« Reply #2 on: August 07, 2007, 01:16:25 pm »
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:

Code: [Select]

<?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;?>