From: "Shlomi Fish" <[EMAIL PROTECTED]> > > I have three tables: clubs, users and permissions. clubs contains a > Club_ID (an integer). users contains a User_ID. Permissions contains both > as well as a Subjects field (a boolean). > > Now, a user is allowed to edit the data associated with a club if he has a > record in the permissions table (with the appropriate User_ID and > Club_ID). He is allowed to edit the subjects if the Subjects field is set. > > Now, I want to make one query that given a User_ID will return a list of > all the clubs in clubs with the following three fields: > > 1. Club_ID > 2. Whether a record exist in Permissions. > 3. If so, whether the Subjects flag is set (or if 2 is false - > undetermined)
I'm not sure what you mean by that. Do you want to return all the clubs that the user have premission to change? If yes, than here's the code: SELECT clubs.Club_ID, premissions.subject FROM clubs,premissions WHERE premissions.User_ID=UID AND clubs.Club_ID=premissions.Club_ID; > > I am using MySQL 3.23.47, but can possibly switch to PostgreSQL. > > Regards, > > Shlomi Fish > Sagi ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]