© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
7 replies
belkocik

How to fetch 2 tables in one query?

Hi, I would like to fetch table:
WiewiorkaMixedRubbish
WiewiorkaMixedRubbish
and
WiewiorkaSegregatedRubbish
WiewiorkaSegregatedRubbish
but it shows me error:
cannot redeclare block-scoped variable 'data'

```js
export const getStaticProps: GetStaticProps = async () => {
  const supabaseAdmin = createClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL || "",
    process.env.SUPABASE_SERVICE_ROLE_KEY || ""
  );

  const { data } = await supabaseAdmin
    .from("WiewiorkaMixedRubbish")
    .select("*")
    .order("id");
  return {
    props: {
      mixedRubbish: data,
    },
  };
// second table i wanted to query at the first supabaseAdmin query. I want return it as another prop called segregatedRubbish
  const { data } = await supabaseAdmin
    .from("WiewiorkaSegregatedRubbish")
    .select("*")
    .order("id");
  return {
    props: {
      segregatedRubbish: data,
    },
  };

};
```
 how can i Combite 1 data query with another table called 
cannot redeclare block-scoped variable 'data'

```js
export const getStaticProps: GetStaticProps = async () => {
  const supabaseAdmin = createClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL || "",
    process.env.SUPABASE_SERVICE_ROLE_KEY || ""
  );

  const { data } = await supabaseAdmin
    .from("WiewiorkaMixedRubbish")
    .select("*")
    .order("id");
  return {
    props: {
      mixedRubbish: data,
    },
  };
// second table i wanted to query at the first supabaseAdmin query. I want return it as another prop called segregatedRubbish
  const { data } = await supabaseAdmin
    .from("WiewiorkaSegregatedRubbish")
    .select("*")
    .order("id");
  return {
    props: {
      segregatedRubbish: data,
    },
  };

};
```
 how can i Combite 1 data query with another table called 
WiewiorkaSegregatedRubbish` ?
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

How to insert to multiple tables in one request?
SupabaseSSupabase / help-and-questions
4y ago
Failing to fetch data from tables in expo
SupabaseSSupabase / help-and-questions
4y ago
Issue to query foreign tables
SupabaseSSupabase / help-and-questions
4y ago
Tables In Tables?
SupabaseSSupabase / help-and-questions
4y ago