Subject | Re: [firebird-support] Firebird SQL Query question |
---|---|
Author | Mitch Peek |
Post date | 2007-06-12T20:11:51Z |
myles@... wrote:
USER_GROUP_MEMBERSHIP is table to establish a many-to-many relationship?
If so, there are several ways but... perhaps something like this..
There is probably a more efficient manner. but if you have only a few
rows, it shouldn't matter.
I don't suppose you have hundreds of Groups. And that you have the
user_group_membership linking column indexed, all of which makes this
plenty fast given moderate amounts of data.
select * from User_Group
where ID not in (Select User_Group_ID from User_Group_MemberShip UGM
where UGM.User_Account_ID=<BLAH>)
> I have a SQL query question that I'm hoping someone can point me in theYou didn't tell us the relationship between these tables. I assume that
> right direction on.
>
> I have two main tables, and a join table. The tables are as follows:
>
> USER_ACCOUNT
> USER_GROUP
> USER_GROUP_MEMBERSHIP
>
>
USER_GROUP_MEMBERSHIP is table to establish a many-to-many relationship?
If so, there are several ways but... perhaps something like this..
There is probably a more efficient manner. but if you have only a few
rows, it shouldn't matter.
I don't suppose you have hundreds of Groups. And that you have the
user_group_membership linking column indexed, all of which makes this
plenty fast given moderate amounts of data.
select * from User_Group
where ID not in (Select User_Group_ID from User_Group_MemberShip UGM
where UGM.User_Account_ID=<BLAH>)
> I need to find all the USER_GROUPS that a USER_ACCOUNT is NOT a member of.
>
> This is simply for each USER_GROUP that does not appear referenced in the
> USER_GROUP_MEMBERSHIP table for the USER_ACCOUNT.
>
>