[thelist] what kind of join is this?
rudy
rudy937 at rogers.com
Wed Jul 23 18:22:36 CDT 2003
> Hopefully that makes more sense.
not to me, but then i'm a weird old fart
let's start with the basics
the login table has one row per person, right?
so PK=logid
the group_membership has one row for every role that a person plays in a
group
so PK=(logid, groupid, role)
so one of the problems you had was to select users who "do /not/ appear in
the group_membership table for a specific group"
okay, that's easy
select logid, first, last, middle
from login
left outer
join group_membership
on login.logid = group_membership.logid
and group_membership.groupid = 10
where group_membership.logid is null
basically, you're asking the database to do a left outer join to a specific
groupid, and for those left table logids where there's no match, they will
be returned with a null in the logid of the right table
that's your basic WHERE NOT EXISTS (subquery) construction which mysql does
not support until 4.1
rudy
More information about the thelist
mailing list