Subject Re: [firebird-support] Firebird SQL Query question
Author Mitch Peek
myles@... wrote:
> I have a SQL query question that I'm hoping someone can point me in the
> right direction on.
> I have two main tables, and a join table. The tables are as follows:
You didn't tell us the relationship between these tables. I assume that
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