SupabaseS
Supabase2y ago
Ebi

inner join without foreign key relationship

Is it possible to do an inner join with supabase js client without "direct" foreign key relationship?

Working SQL example in supabase sql editor:

select profiles.first_name, profiles.last_name, user_id
from profiles
inner join organization_users
on organization_users.user_id = profiles.id
where organization_users.organization_id = 1


Tables:

profiles
  • id
  • first_name
organization_users
  • id
  • user_id
  • organization_id
The profiles.id and organization_users.user_id both reference auth.users.id.

When I try the following js code I get an error message "Could not find a relationship between 'profiles' and 'organization_users' in the schema cache":

await supabase
.from("profiles")
.select(",organization_users()")
Was this page helpful?