# Foreign Table

Let's say you have a table called "Post" and each post have a "Category". With a simple query you can return both table with just 1 API call, and you can also limit the number of columns you wish to return to save on data transfer costs.&#x20;

For that you need to first initialize that call in the API connector just like with every other. You can query and filter down several levels but this guide only shows the basics.

First let's initialize the call:

<figure><img src="/files/OP9Icy9UsxkztPzuRRS5" alt=""><figcaption></figcaption></figure>

Same as before, but here we actually need to specify the Data we wish to return.&#x20;

<figure><img src="/files/kreANUuxkJr4fQjpQpd1" alt=""><figcaption></figcaption></figure>

Let's break it down:

First we add the columns for the "Post" Table, we can just insert a "\*" here to return everything. after we add a comma, and now we can add the name of the column for the Foregn Table we have, in this case "category\_ft" and inside a bracket we can add the columns we'd like to return as well. We can also use an asterisk as well.&#x20;

If you wish to go down more levels, so let's say the "Category" table also have "user" which is a "User" table, you can add after the 'select': \*,category\_ft(name,id,user(\*)). This would yield this result:

<figure><img src="/files/rHRxYZ0FYefU9tcMNXQY" alt=""><figcaption></figcaption></figure>

After you have the basic setup done. Now we can setup the plugin this way. Let's add a dropwdown to filter for the Categories.

<figure><img src="/files/W3m8rJy7Um0b6Ype8vFB" alt=""><figcaption></figcaption></figure>

This will show the "Category" table so we can dynamically filter the API call later.

Next step to setup the actual "Post" Data element. Here we can add the filter for the query, so that we specify that the name of the foregn table has to match the dropdown's value.

![](/files/YYcqdml1RxqtC7YSAwvB)

As you can see we're returning the same table, and the same columns as we've specified in the API connector.

For the filter we can add the name of the column for the foreign table followed by a dot and after the name of the column inside the foreign table we wish to filter on.

With everything setup here's the feature.

<figure><img src="/files/fTsG0WKi5E3TXjc1zoI3" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.relevat.hu/supabase.js-bubble-plugin/setup/supabase-data/foreign-table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
