Ask Your Question
2

How to extract information from a one-to-many relationship in Supabase?

asked 2023-03-24 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-04-26 04:00:00 +0000

qstack gravatar image

To extract information from a one-to-many relationship in Supabase, you can use a JOIN clause in a SQL query. For example, let's say you have two tables, "orders" and "order_items", where each order can have multiple items. To extract information from both tables, you can use the following query:

SELECT orders.*, order_items.*
FROM orders
JOIN order_items ON orders.id = order_items.order_id
WHERE orders.id = 123

This query will return all columns from both tables for the order with the ID of 123, and will join the tables based on the "orderid" column in the "orderitems" table and the "id" column in the "orders" table. You can customize the query to retrieve specific columns and filter the results as desired.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-24 11:00:00 +0000

Seen: 13 times

Last updated: Apr 26 '22