# Some tricky queries with relations

**URL:** <https://community.glideapps.com/t/some-tricky-queries-with-relations/12213>\
**Category:** Feature Requests\
**Created:** [July 9, 2020, 11:54am UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213 "2020-07-09T11:54:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thibault\_Milan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thibault_milan/32/4970_2.png) [@Thibault\_Milan](https://community.glideapps.com/u/Thibault_Milan)\
**Post date:** [July 9, 2020, 11:54am UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/1 "2020-07-09T11:54:42Z")

</div>

Hi everyone,

I have a table of deks

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/2/275476254c26e3f0da09b4b47106184125ea15f4.png)  
and users  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/3/391503b69c4221958e005e169a5ae9a7adc125b8.png)  
and bookings  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/4/4defe41ce4e517ba374002fea7d217f27fb88a8b.png)

As you can see, I try to know if the user have a booking for today or tomorrow.  
I used a rollup that can return me the latest booking so if a user book just for today (and have the previous booking) that’s fine. But if a user book for tomorrow, I’m screwed.

Any idea of how I could have a boolean for is\_seated\_today and is\_seated\_tomorrow?

Bonus question: if I can get them today and tomorrow booking details (like with a relation) it would be even better.

---

<div class="post-metadata">

**Author:** ![Thibault\_Milan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thibault_milan/32/4970_2.png) [@Thibault\_Milan](https://community.glideapps.com/u/Thibault_Milan)\
**Post date:** [July 9, 2020, 1:16pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/2 "2020-07-09T13:16:07Z")

</div>

Another way would be able to filter a relation column for (or test it for the presence of) a particular date.

So my `Booking` relation would be filtered or tested with `today` and `tomorrow` column

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 9, 2020, 11:12pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/3 "2020-07-09T23:12:58Z")

</div>

Have you been able to solve this?

---

<div class="post-metadata">

**Author:** ![Thibault\_Milan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thibault_milan/32/4970_2.png) [@Thibault\_Milan](https://community.glideapps.com/u/Thibault_Milan)\
**Post date:** [July 10, 2020, 7:01am UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/4 "2020-07-10T07:01:16Z")

</div>

not yet

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 10, 2020, 8:13am UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/5 "2020-07-10T08:13:21Z")

</div>

Can you try this:

- Make a relation matching the “today” column to the “bookings” column. If the relation is not empty (as in it returns something) then Is\_Seated\_Today = True.

- Do the same for “tomorrow”.

The “Today” and “Tomorrow” columns will be changed, so the boolean If \> Then \> Else columns will be changed as well.

---

<div class="post-metadata">

**Author:** ![Thibault\_Milan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thibault_milan/32/4970_2.png) [@Thibault\_Milan](https://community.glideapps.com/u/Thibault_Milan)\
**Post date:** [July 10, 2020, 7:05pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/6 "2020-07-10T19:05:35Z")

</div>

> [@ThinhDinh](#):
>
> Make a relation matching the “today” column to the “bookings” column. If the relation is not empty (as in it returns something) then Is\_Seated\_Today = True.

It can’t work. Because then the relation will be only on the date, and gonna match the first booking for today no matter if it’s the current user or not.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/d/df7b54534ae8ed47b73288fc15615716954bf771.png)

- At least it missing being able to put multiple conditions on a relation.
- Or being able to select a relation column to make a relation 😁
- Or being able to do a CONTAIN condition on a IF THEN ELSE on Booking

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 11, 2020, 2:25pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/8 "2020-07-11T14:25:28Z")

</div>

Just to confirm, what you want to return is whether in the bookings users have made, is there one that match today, and one that match tomorrow. Is that correct?

---

<div class="post-metadata">

**Author:** ![Thibault\_Milan](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thibault_milan/32/4970_2.png) [@Thibault\_Milan](https://community.glideapps.com/u/Thibault_Milan)\
**Post date:** [July 11, 2020, 3:22pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/9 "2020-07-11T15:22:49Z")

</div>

if in all the bookings made by the users (likely one every day) there’s one with the date = TODAY and one with the date = TOMORROW

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 11, 2020, 3:32pm UTC](https://community.glideapps.com/t/some-tricky-queries-with-relations/12213/10 "2020-07-11T15:32:37Z")

</div>

What I mean for the relation was to match the today column to the “Booking” relation you have returned. Can you try that?
