© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
hko

Limit on foreign table to filter select query?

Hi,

I'm a bit stuck trying using limit/order on foreign tables:
const { data, error } = await client
  .from("user_content_queue")
  .select(
    "title, content, type, target_url, format, priority, id, published_at, digest_id (id, created_at)"
  )
  .order("created_at", { foreignTable: "digest_id", ascending: false })
  .limit(1, { foreignTable: "digest_id" })
  .order("type", { ascending: false })
  .order("priority", { ascending: true });
const { data, error } = await client
  .from("user_content_queue")
  .select(
    "title, content, type, target_url, format, priority, id, published_at, digest_id (id, created_at)"
  )
  .order("created_at", { foreignTable: "digest_id", ascending: false })
  .limit(1, { foreignTable: "digest_id" })
  .order("type", { ascending: false })
  .order("priority", { ascending: true });


Multiple pieces of content belong to a single digest. With this query, I want to retrieve all content items that belong to the latest query. While the query runs without any errors, it does not limit the digests to the latest id, but rather returns all digests.

Any ideas on how I might get this to work?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

foreign key select query question
SupabaseSSupabase / help-and-questions
4y ago
Query foreign table twice, once directly, once through join table
SupabaseSSupabase / help-and-questions
4y ago
Issue to query foreign tables
SupabaseSSupabase / help-and-questions
4y ago
How to filter on joined table
SupabaseSSupabase / help-and-questions
4y ago