© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
3 replies
LukasV

How to fetch single rows randomly?

Hello, I have a situation where I need to fetch recipes 1 by 1.

Correct me if I'm wrong but so far it seems that If was to fetch unique recipes like this:
supabase
    .from('recipes')
    .select(
      `*`,
      { count: 'exact' }
    )
    .limit(1)
    .not('id', 'in', `(${fetchedRecipeIds})`);
supabase
    .from('recipes')
    .select(
      `*`,
      { count: 'exact' }
    )
    .limit(1)
    .not('id', 'in', `(${fetchedRecipeIds})`);

10 queries would simply return results in this id sequence - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 correct?

As you can see from the picture first 4 results are recipes with tuna, which would result in bad UX for users who want to fetch recipes 1 by 1.

How can I make it random or at least group them so that I know that the next recipe user fetches won't be from the same "group".

Ideally result sequence would looks something like this:

Tuna..., chicken..., pizza..., tuna..., chicken and so forth...
Screenshot_2022-09-28_at_21.07.55.png
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

number of rows limit in a single table
SupabaseSSupabase / help-and-questions
6mo ago
what's a better way to fetch a single user
SupabaseSSupabase / help-and-questions
4y ago
Large update of 1800 rows stalling out and erroring with 'failed to fetch'
SupabaseSSupabase / help-and-questions
4y ago
Failed to fetch?
SupabaseSSupabase / help-and-questions
3mo ago