# How would you filter a JOIN query in Supabase Plugin?

**URL:** <https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030>\
**Category:** How do I?\
**Tags:** supabase\
**Created:** [August 25, 2023, 7:38pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030 "2023-08-25T19:38:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 7:38pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/1 "2023-08-25T19:38:37Z")

</div>

Hey, I’m trying to filter JOIN statement in WeWeb’s Supabase Plugin.  
I have a query like this in SQL

 ![Screenshot 2023-08-25 at 21.35.06](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/bb843dc5dcc5613a2f96784e329309d54abddcbb.png)

In Supabase I got this far

 ![Screenshot 2023-08-25 at 21.35.53](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/eb95816f943793d3707a4c75a322900ac00e605d.png)

But when it comes to filtering, it is pretty tough,

 ![Screenshot 2023-08-25 at 21.38.22](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7910a5fc68df2a9c99a53e817822a5880e333d24.png)

---

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/matthieu/32/1288_2.png) [@Matthieu](https://community.weweb.io/u/Matthieu)\
**Post date:** [August 25, 2023, 9:09pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/2 "2023-08-25T21:09:12Z")

</div>

Hey Rob,

There’s 2 things you can do here.

1. You can join in WeWeb the two tables you need :  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d7207277a64276590ced1ab83dddc569dae8e04c.png)  
Here I tell table steps that it’d be nice to get the label from the type on the table linked by the type\_id.  
You should be able to filter then.

BUT : i don’t like this approach anymore (for perfs). So solution 2 :  
I tend to create VIEWs in Supabase  
`create view myview as select * from table1 join table2 on…`  
and then use that view as a collection in WeWeb. That’s waaaay faster (according to me anyway).

I hope it helps.  
Have a nice night.

Matth-

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:11pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/3 "2023-08-25T22:11:38Z")

</div>

Hey Matthieu, thanks for your view on the topic 🙂  
I’m not sure if I can go with views because they dont seem to support row level security. And as for the first proposal, I’m already joining tables with standard joins, but I’m unable to filter the joined result because it gives me back array and then the thitd screenshot happens, with an error also, which is not optimal either, as I can only access the array it seems.

I really appreciate your input though 🙂 maybe @Alexis would know of a workaround

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:13pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/4 "2023-08-25T22:13:09Z")

</div>

Basically I’m doing the first one you mentioned but the filter seems to not work on the joined array result, as it treats it as a column for some reason?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:15pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/5 "2023-08-25T22:15:24Z")

</div>

![Screenshot 2023-08-26 at 00.17.44](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/02de768098356ecff7e237f5c26ae2dea3fb9532.png)

---

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/matthieu/32/1288_2.png) [@Matthieu](https://community.weweb.io/u/Matthieu)\
**Post date:** [August 25, 2023, 10:15pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/6 "2023-08-25T22:15:39Z")

</div>

> [@Broberto](#):
>
> oposal, I’m already joining tables with standard joins, but I’m unable to filter the joined result because it gives me back array and th

Yes they do actually.  
If you created your view with the correct syntax, the view will only show what the table can display to your user through the RLS.

`drop view public.myview;`  
`create view public.myview with (security_invoker=on) as select………`

So yes to views 😃

As for the filters, I have sometimes troubles to filter collections in WeWeb when the first row is not filled with non null values.

---

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/matthieu/32/1288_2.png) [@Matthieu](https://community.weweb.io/u/Matthieu)\
**Post date:** [August 25, 2023, 10:18pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/7 "2023-08-25T22:18:08Z")

</div>

> [@Broberto](#):
>
> e first one you mentioned but the

I think you have to list what you want for all those tables instead of the stars.

```auto
employee_id,
name,
surname,
job: employee_id(job_id, date)
```

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:20pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/8 "2023-08-25T22:20:10Z")

</div>

If you check out, I corrected it, in the comment higher. When I filter it, I get an error though.

 ![Screenshot 2023-08-26 at 00.19.45](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/cd2924b2445a73fb769e1707c5ab0ee850916e6f.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:24pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/9 "2023-08-25T22:24:31Z")

</div>

@Alexis seems like it treats the array as a column. It would be fantastic, if instead there were the joined columns, that would be super fantastic : )

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 25, 2023, 10:36pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/10 "2023-08-25T22:36:28Z")

</div>

Hmm, I might have to use views, but that is not really something I’d be wanting to do like always. As I also cannot filter them directly via a variable. But seems like the only viable option, security invoker is a new thing, isn’t it? 🙂 Haven’t heard about it before

Edit: Seems like you were right and if this doesn’t get fixed somehow, views will be a good option. Thank you very much for the idea @Matthieu, could you elaborate on the performance concerns regarding the WeWeb “Advanced” WeWeb joins? I thought they were the same. I know there might be some JS behind it all, but in the end it is a call through SDK. Is it that the views are already “ready” there?

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [August 28, 2023, 9:10am UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/11 "2023-08-28T09:10:32Z")

</div>

I think what is missing is the ability to select a subproperty, or type what you want like “job.date” as field instead of only job

We plan to explore this blocker for the next supabase update 🙂

For now I think the only solution is view as @Matthieu suggested

Edit : And for the warning message when putting \* symbol in the field, its a false flag, we forgot to handle this case when checking your input

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 9:12am UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/12 "2023-08-28T09:12:03Z")

</div>

Hey, thanks for the answer! Is there any chance to see what features you have planned and the estimated date? You might want to post it here, so we can add some things that might be missing for us so you can consider adding them 🙂

---

<div class="post-metadata">

**Author:** ![Matthew](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Matthew](https://community.weweb.io/u/Matthew)\
**Post date:** [October 12, 2024, 1:00am UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/13 "2024-10-12T01:00:02Z")

</div>

Super late response here but fwiw you can make an API call directly to supabase (not the plugin) using the following PostgREST format.

This example uses an email to look up what orders a particular profile has made (known by a profile\_id on the order record, and we search the profiles table by email instead of profile id with an inner join)

`*{your supabase url}*/orders?select=*,profiles!inner(email)&profiles.email=eq.test@example.com`

1. **`/orders`** : This is the main endpoint we are querying, meaning we want to retrieve records from the `orders` table.
2. **`select=*,profiles!inner(email)`**:

- `*` retrieves all columns from the `orders` table.
- `profiles!inner(email)` tells PostgREST to include data from the `profiles` table using an **inner join** on the foreign key.
  - **Inner Join** : This limits results to only `orders` rows that have a corresponding record in `profiles`.
  - `(email)`: Specifies that only the `email` column from `profiles` should be included in the results.

1. **`profiles.email=eq.test@example.com`** :

- This filters `profiles` by email. Only records where `profiles.email` matches the specified email will be included, enforcing the filter through the join.

The combination of `select=*,profiles!inner(email)` with `profiles.email=eq...` ensures that:

- Only `orders` records with a related profile matching the email are returned.
- The **inner join** excludes any `orders` records without a matching `profiles` entry, filtering results to exactly what you need.

For more info see the PostgREST docs: [Resource Embedding — PostgREST 12.2 documentation](https://docs.postgrest.org/en/stable/references/api/resource_embedding.html#top-level-filtering)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [October 12, 2024, 8:39am UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/14 "2024-10-12T08:39:56Z")

</div>

Hey, I meanwhile mastered Supabase and wrote a few articles including how to do this effortlessly without involving REST.

> **[Become a Supabase Magician in WeWeb (Tutorial With Examples) – Broberto](https://broberto.sk/radar/weweb/become-a-supabase-magician-in-weweb-with-examples/)**
>
> Discover advanced techniques for using Supabase with WeWeb. Enhance your apps with these advanced examples and interactive WeWeb examples.

---

<div class="post-metadata">

**Author:** ![Ben1](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Ben1](https://community.weweb.io/u/Ben1)\
**Post date:** [May 9, 2025, 4:31pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/15 "2025-05-09T16:31:33Z")

</div>

> [@Broberto](#):
>
> ight want to post it here

Hi all, and hi @Broberto

Many thanks for all these advices such a great job. Also I really appreciate the Weweb team Supabase plugin V2 work @Alexis 👏

I have an error during filtering by a column of a join table that tell me : “column link\_events\_domaines\_invitations.is\_actif does not exist”.

My case : I have in Supabase one table named “events”, another named “domaines” and the last for the many to many join implementation named “link\_events\_domaines\_invitations” with “event\_id” and “domaine\_id” column inside.

So on Weweb side I make a collection and get data from “link\_events\_domaines\_invitations” table like this :

 ![How would you filter a JOIN query in Supabase Plugin - Ask us anything How do I - WeWeb Community - Google Chrome](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/1599e0703979d1d01d204e8d62ab09c234fa554a.jpeg)

I get well my data like this and more precisly with the “is\_actif” column that is located in “events” table :

 ![Oeno2win webapp WeWeb - Google Chrome](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0387a7d0760fb09590e48c7bdf9aa85f80bbd5c8.jpeg)

Now I ty to filter by “is\_actif = true” but the error “column link\_events\_domaines\_invitations.is\_actif does not exist” is raised :

 ![Oeno2win webapp WeWeb - Google Chrome_2](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/de504790e4872b7bd4a47e03996cc568dbaa90ee.jpeg)

I can understand this because the “is\_actif” column is not directly in my table “link\_events\_domaines\_invitations” where I ask my data but I thought that with the join it will do the job. Am I missing something ? Do I have to make a view ?

Also @Broberto many thanks for your article very interesting. However I didn’t find where you set these filter conditions (during the creation of a collection so in backend filtering or in frontend directly on weweb side ?) :

 ![Become a Supabase Magician in WeWeb (Tutorial With Examples) – Broberto - Google Chrome](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/dcd4746e953c8bffd103a0bf50a3765dee38822c.jpeg)

Regards

Ben

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [May 9, 2025, 4:39pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/16 "2025-05-09T16:39:56Z")

</div>

You need to use the workflow actions and a dot notation - foreign\_table.column

---

<div class="post-metadata">

**Author:** ![Ben1](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Ben1](https://community.weweb.io/u/Ben1)\
**Post date:** [May 9, 2025, 5:06pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/17 "2025-05-09T17:06:42Z")

</div>

I think you are talking about the “Database | Select” workflow because I managed to get the data but it seems that the filter is applied after the call so in the front.

 ![Oeno2win webapp WeWeb - Google Chrome](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/eeace1b052e435d489d20948cbd9b45963ddf24c.jpeg)

Here is my workflow settings :

 ![Oeno2win webapp WeWeb - Google Chrome_3](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/5/5c0a7fe6670a79074af79ff57c8b6ef66bbf808c.jpeg)

As you can see the filtered is applied because the “events” data are null in the object 0 and 2 but I would like to not fetch them at all and only have the first object. I think I have to make a view ecause I may have a lot of data in the futur I would like to filter in backend what do you think ?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [May 9, 2025, 5:40pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/18 "2025-05-09T17:40:36Z")

</div>

You need to make it events(event\_id) I think. Or events(\*) for everything, right?

---

<div class="post-metadata">

**Author:** ![Ben1](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Ben1](https://community.weweb.io/u/Ben1)\
**Post date:** [May 9, 2025, 5:54pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/19 "2025-05-09T17:54:35Z")

</div>

Both events(\*) and events:event\_id(\*) are working well (just with events:event\_id(\*) I specify the foreign key name in my source table). events(event\_id) raises an error. This has an impact on how you can see your data from the joined table but it does not impact the filtering.

I’m wondering if it can be a bug or we can’t just filter on a column from a joined table on backend side (when filtering during the creation of the collection) @Alexis

I’m going to make a view waiting for weweb answer. Big thanks to you @Broberto for responding so quickly !

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [May 9, 2025, 6:28pm UTC](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030/20 "2025-05-09T18:28:20Z")

</div>

I think the view is overall a more sustainable approach 🙂

[Next page](https://community.weweb.io/t/how-would-you-filter-a-join-query-in-supabase-plugin/4030.md?page=2)
