App Finishers

Fix guide · updated 2026-11-16

Supabase "Could not embed because more than one relationship was found" (PGRST201)

Could not embed because more than one relationship was found for 'messages' and 'profiles'

A query that reads a table together with a related one, like select('*, profiles(*)'), fails with "Could not embed because more than one relationship was found for 'messages' and 'profiles'", code PGRST201. There are two ways to get from one table to the other, and Supabase won't guess which one you mean. The error already contains the fix. We reproduced both usual setups on Supabase's Data API (PostgREST 13, November 2026).

What the error means

When you put a table inside select(), Supabase follows the foreign key between the two tables. Here it found more than one path:

In our test both answered HTTP 300 (Multiple Choices) with PGRST201, and a hint that lists the names to use: "Try changing 'profiles' to one of the following: 'profiles!messages_receiver_id_fkey', 'profiles!messages_sender_id_fkey'". In supabase-js it's in error.hint. A query that worked yesterday breaks this way as soon as a migration adds the second path.

Fix: say which foreign key to follow

Put ! and the column that holds the key after the table name, and give each embedded table its own name:

const { data, error } = await supabase
  .from('messages')
  .select('*, sender:profiles!sender_id(name), receiver:profiles!receiver_id(name)')

In our test this returned both people: data[0].sender.name and data[0].receiver.name. The constraint name from the hint works after the ! too, as in profiles!messages_sender_id_fkey(name). Then update the code that reads the result: it now finds the person under sender and receiver, not under profiles.

The other direction needs the same: supabase.from('profiles').select('*, messages(*)') failed the same way in our test, and select('*, messages!sender_id(body)') worked, returning the messages each person sent.

A direct key and a junction table

For posts and tags linked both ways, name the path you want. In our test:

If an AI tool built your app

Give your AI tool this prompt, with your own tables:

This Supabase query fails with PGRST201: Could not embed because more than one relationship was found for 'messages' and 'profiles'. In every select() that embeds profiles from messages, name the foreign key and the result: sender:profiles!sender_id(...) and receiver:profiles!receiver_id(...). Update the code that reads those results to use sender and receiver. Don't change anything else.

Not quite your error?

Still stuck?

Read the details list in the error: each entry describes one path, like "messages_sender_id_fkey using messages(sender_id) and profiles(id)". Choose the column whose meaning you want, and put it after the !.

Other Supabase problems? See Supabase fixes.