Limit query results

quick question…how can i modify the query to only return limited results. For instance, i only want to show 3 of the most recent inventory items. My sql query would look like this

SELECT * FROM inventory ORDER BY inventoryNum LIMIT 3

but i can’t seem to figure out how to add the LIMIT to the end of the query.

Are you using a paged query or a regular multi-record query?

multi-record query

Just use a paged query instead. It has a limit option, which is used in cases like this.

You can use the ‘top’ formatter in your repeat expression.

excellent - thank you.

Okay, i tried this and set it up, but i think i am missing something.
I have one row with 3 columns. I want the 3 newest records to display in each column. SO it would show all 3. When i set it up the way you recommend, it shows the same inventory item for all 3 columns.

Do i setup the repeat on the Row or on the individual column?

Add the repeat to your column.

As for showing the same data three times you likely simply bound the data from the recordset instead of from within the repeat. Common mistake.

Can you post a link or paste your repeat element code in here?

yes, i did try to get the data from the Column, but when i selected that the loading icon just spins without displaying anything, so i figured that was not correct. I only had access to the ServerConnect data. You can see from the image below where the column data just has a ‘loading’ circle and doesn’t populate.

her is the div for the repeater. Obviously right now the

data is where the repeat data will go, but not sure where to select the bindings for this?

It would be easier and better to change the query type to paged query and set the limit to 3. This way the query results will be limited on the server side and not loaded at all.
Then select the repeater expression on the page again.

i did try that…and put the Limit to 3…but its not just limiting the results. As you can see, its pulling all of the inventory in the repeat section

Maybe the design view just hasn’t refreshed?

Have you saved your server action and what is the expession you are using for the repeat?
How many values do you see when you directly run your server action in the browser:

when i open the server action, i see ALL of the data
I just can’t figure out how to only get the last 3 results. Seems like such a simple function but nothing i do is working

even in my query builder it says only 3 rows

okay, i just went in an removed all server functions and recreated them from scratch. Renamed everything so there was no issue. The paged results seemed to work correctly now.

I have no idea why the other paged recordset didn’t work. maybe because i started out with a single query and changed it to a paged query that was causing the issue?

1 Like

sorry to keep this thread open, but unfortunately i am still having an issue.
So i was able to create the query with the 3 results. That displayed okay.

when i run that it shows just the 3 records

now when i try to Inner Join another table to get the data from that record, i get a server error

any thoughts?
can i not have an inner join on a page query?

Well please enable the debug option in server connect settings so we can see the exact error.
Also please show a screenshot of how have you joined your tables?

i use InventoryNum in both the data and the photos database table to join them.

Please use aliases if the field names are the same.

yes, i tried that too and it has the same error