Limit inside SQL query as a variable

Hi,

I know I have to use LIMIT < 201 in the SQL queries.
I want to build an interface where user will select the number and based on this number a query will be performed.
For example user will select 3 and then the limit in my query will be 3, if user picks 7, then limit will be 7.

Is it possible to add a limit as a variable? I tried and it doesn’t work
This is what I tried so far where I set like this LIMIT = $1 and it still wants to me to add a limit of max 200

@jernejfuture This post might be worth reading: SQL Database Connector connection issues

The default connector has various limitations of which this is one. You could potentially solve this problem by querying for the 200 records and then doing a client side filter (within the Bubble editor/interface designer). This wouldn’t be the most efficient solution but it would work if you don’t even need more than limit of 200 records.

If you need more flexibility, we built a paid plugin to support more complex queries and offer developers greater options when connecting to a SQL database. You can find the link to that plugin here: SQL Database Connector Pro Plugin | Bubble

1 Like

Thank you for the answer.
Maybe that would be the solution because I don’t need more than 200 results but I don’t know how to filter on the client side. I want to get averages of the last 3,5,7 etc depends on what user will select.
I wanted to do this with a dropdown but I don’t know how.
So for example if user will select 5, then I will get the average from the last 5 from the table, if 7 then it’s going to be 7 etc.
I hope I’m clear enough.
This is my dropdown but for now I’ve been playing with direct SQL query without success.
Screenshot 2023-05-02 132824

I think you are looking to do something like this: Pagination / Offset (MSSQL) - SQL Database Connector Pro