Advance SQL query needed.

Solutions for other advanced phplisters

Advance SQL query needed.

Postby mani » 7:05pm, Thu 25 Feb, 2010

I need sql query to do the following

I have 7 lists.

List number 7 contains all my email addresses including addressess from lists 1 - 6.

Lists 1 to 6 are lists broken down by domains.

I want to do the following query.

If the person is in the list 1 then i want to remove the person from list 7
If the person is in the list 2 then i want to remove the person from list 7

and so on

This way the list 7 will have only the people who are not on any other list.

Note: I want to remove the person from the list but not DELETE THE PERSON from db

Thank you
mani
phpLister
 
Posts: 6
Joined: 4:16am, Fri 01 Jan, 2010

Re: Advance SQL query needed.

Postby CS2 » 5:17pm, Mon 01 Mar, 2010

Code: Select all
DELETE FROM phplist_listuser
WHERE listid IN (1,2,3,4,5,6)
AND userid IN (
  SELECT userid FROM phplist_listuser
  WHERE listid = 7
);


I have not tested the above, but it should work. However, make CERTAIN you do the following before executing it:
1) Backup your database.
2) Make sure your table prefix is "phplist_" (or adjust the table name to account for the prefix you use)
3) Make sure your list IDs are really 1-7 (and that list ID 7 is your combined list) and adjust accordingly if they are not.
CS2
PL Master
 
Posts: 216
Joined: 2:20am, Wed 04 Feb, 2009


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest