This query is getting me a bit turned around. In a Postgresql (Express/Knex/Objection) database, I have three tables, Users, Groups and an associative table Memberships s.t. Users have_many Groups through Memberships.
For a specific User's Groups, I want to return all other Users who have Memberships with those Groups.
to answer the questions below, given one user I want to return all other distinct users who belong to any group which also includes the first user.
I think I am getting flummoxed by the fact that I have Users on both sides of the join. I imagine people have solved this multiple times over, but I am not finding any examples online. Per requests, including table schema:
Users: