I want to list the all 'Groups' that 'Users' belong to as indicated by the User2Group link table - as well as the Groups the user does not belong to. This returns the desired data set except it is not filtered for a particular user,
# output not filtered for user s.query(Group, User2Group).outerjoin(User2Group).all() # psuedo output - not filtered: # Group 1 <Yes> # Group 2 <Yes> # Group 2 <Yes> # Group 3 <Yes> # Group 2 <Yes> # Group 4 <Yes> # Group 1 <None> # Group 2 <None> # Group 3 <None> # Group 4 <None> If I add a filter, then then the query seems to become more like inner join as both Group and User2Group are filtered for user_id = 5 # groups not linked to id = 5 excluded s.query(Group).outerjoin(User2Group).filter(User2Group.user_id==5).all () # Output too filtered: # Group 2 <Yes> # Group 3 <Yes> Any suggestions how I can return a list of all groups and show where there is a User2Group record for e.g. User ID 5 # Desired output: # Group 1 <None> # Group 2 <Yes> # Group 3 <Yes> # Group 4 <None> thanks for any suggestions --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---