|
Posted by Simon on 01/30/06 23:48
mailinglist(listid, name)
subscribers(userid, listid)
users(userid, username)
SELECT ml.name from mailinglist ml,subscribers s, users u
WHERE u.userid=s.userid
AND ml.listid = s.listid
AND u.userid = $user_id
pass the $user_id for the given userid and you will get all mailing list
names that the user has subscribed to
"lallous" <lallous@lgwm.org> wrote in message
news:444lnsFcecpU1@individual.net...
> Hello list,
>
> I have three tables:
>
> mailinglist(listid, name)
> subscribers(userid, listid)
> users(userid, username)
>
> A given user can belong to multiple mailing lists and his membership is
> defined by an entry in subscribers table.
>
> How can I write a 3.23 compatible MySQL statement to list all mailing
lists
> names and a field that designates whether a user with a given ID is
> subscribed to it or not?
>
> Currently, I am doing two queries then glueing them through a PHP script.
>
> Regards,
> Elias
>
>
Navigation:
[Reply to this message]
|