you can use
select addresses.id from addresses LEFT JOIN mlist ON
addresses.id=mlist.addr_id AND mlist.mlist_id=$mlist_id WHERE mlist.mlist_id
IS NULL
On Thu 27. September 2001 08:09, Adam Gintis wrote:
> I have the following table mlist:
>
> +--+-+
>
> | mlist_id | addr_id |
>
> +--+-+
>
> |1 | 1 |
> |2 | 2 |
> |2 | 3 |
> |1 | 3 |
>
> +--+-+
>
> This is the join table of my address book and my mailing lists. So person 1
> is in list 1, person 2 is in list 2, and person 3 is in both lists.
>
> What I want to do is get a list of everyone that is NOT in a certain list.
> In other words, if I'm editing list 1, I need a list of all the people in
> the address book that aren't in list 1 (person 2). If I'm editing list 2, I
> want person 1. I never want to see person 3, because he is already in both
> lists.
>
> I'm currently trying to do this with a statement like "SELECT * FROM mlist
> GROUP BY addr_id HAVING mlist_id != 'list I'm currently editing'". The
> problem is that group by addr_id keeps the first row's value for mlist_id.
> So when I'm editing list 2, it works. But when I'm editing list 1, person 3
> still shows up. If the last two rows were the other way around in the
> table, it would work for list 1 and not for list 2.
>
> So the question is, is there a command I can use to look through the
> aggregate set of mlist_id's, or is there another way to write this query?
>
> Thanks!
>
>
> ---
> Adam Gintis
> Vanderbilt University
>
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php (the manual)
>http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php