Forum Academy Marketplace Showcase Pricing Features

Use queries on bubble database

Hello guys, here is me again with some hard question for you :slight_smile:

There is a way to use queries in bubble database ( not a external database). I’m saying that because now I’m using 2 repeating groups to create the final list but I could easily have the same result with a more complex query.

Maybe a plug-in … I don’t know :slight_smile: thanks again

What are you trying to do?

Basically, I have two table:

1 - owner: that can offer a maximum space defined by him ( let’s say 3 space in the room)

2 - bookings: a booking order and the space booked as long with the dates of checkin and checkout

Basically I want to search all user, except all user that has full booking in a specific data range.

Exemple: if a use offer 3 spaces but has 2 booking order, one taking 1 space and other booking order taking 2 space, this user should not be visible in my search because he reaches the maximum space offered by him, 3

If you’re asking can you do SQL queries eg to join tables then the answer is No and there’s no way around that with Bubble’s DB. There are little tips and tricks you can do which mimic joins such doing a nested Search For in constraints but they’re not optimised so unless you know that the amount of data that you’re querying for is quite small (no more than a few hundred records) then I’d stay away from them. Usually the answer is duplicated data in a join table that you use as your main way to access the data you want in the way you want. Use backend triggers to keep the duplicated data synchronised whenever the source data is updated etc.

It’s not pretty but it’s effective.

1 Like

Just to give feedback to everyone, I used a repeating group inside a repeating group and using the RG extractor plugin to create the table. Its helped me to solve my problem.