Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Querying nth table by joining n-1 tables. #440

Description

@KamaniBhavin

Improve documentation

Link

https://supabase.com/docs/reference/javascript/select

Describe the problem

I recently encountered a scenario where I needed to join three tables - product, supplier, and manufacturer - and filter the results based on a column in the manufacturer table.

schema

Product Table:
product_id (Primary Key)
supplier_id (Foreign Key to Supplier Table)

Supplier Table:
supplier_id (Primary Key)
manufacturer_id (Foreign Key to Manufacturer Table)

Manufacturer Table:
manufacturer_id (Primary Key)
max_capacity

However, I found the documentation to be inadequate for my needs. While it provided guidance for querying a single foreign key-constrained table, it didn't offer any information on how to accomplish this with multiple nested tables in the same format.

Describe the improvement

To assist users facing similar issues, I suggest adding an example to the documentation. This would enable them to efficiently join multiple nested tables in the desired format and filter the results according to their requirements.

      db
       .from("products")
        .select(`
            product_id,
            suppliers (
                supplier_id,
                manufacturers (
                    max_capacity
                )
            )
        `)
        .eq("suppliers.manufacturers.max_capacity", maxCapacity)

Additional context

It is also applicable for n nested tables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions