Can anyone suggest the SQL needed to generate the data needed for an html drop down directly from related joined tables -- with the selected flag also set. For example, I have a groups table and a users_groups table. I need to generate a table that lists ALL the groups, and indicates if a particular user is in a group(s) (ie there is a corresponding entry in the users_groups table for that user). So my resulting table would contain, groups.name, groups.group_id and SELECTED_FLAG. I'm sure it must be possible to do this directly in a single SQL statement but I keep meeting myself coming the other way when I try to figure it out...

Thanks for any help


Jonathan