Select spesific records out of database - in range of the count.. does that even make sense

Ok I have a database… sometimes 100 … sometimes 3000 records.
Once in a while i need to display records in a repeat… say records 10 - 20 only… or 63 - 70…

Think my brain is overworked and not thinking logically about this… We have all been there… :slight_smile: please could you give me a solution for this…

I have tried the … option where you select the Top 30 records and then minus the say first 20 … but i dont think this is how that work… im sure there is a very simple solution to this…

<div dmx-repeat:repeat1="((lotsdataview.data.top(10))"> </div> <!-- 1 - 10 ?? -->

or

<div dmx-repeat:repeat1="((lotsdataview.data.top(20)) - (lotsdataview.data.top(10)))"> </div> <!-- 11 - 10 ?? -->

or

<div dmx-repeat:repeat1="((lotsdataview.data.top(30)) - (lotsdataview.data.top(20)))"> </div> <!-- 21 - 30 ?? -->

So what defines this? How do you want control which records to show? Can this be different values or are they always 63-70?

Sorry Teodor… my explanation was very vague …
If i have a 300 records in a database, i want to do is display records (Count) from 10 - 13 or 67 - 71.
Even if the ID of the record is different to the records i want to display… I want to Select records that is in position 10 - 13 out of the database… basically just query those 3 or 4 records in that position out of the complete count / total records.

id item
113 item 10
114 item 11
115 item 12

I will amend the dmx-repeat:repeat1 - manually … as it might always be records 60 - 70 out of the complete database… even if there is 100 or 3000 records…

<div dmx-repeat:repeat1="(lotsdataview.data.count()((lotsdataview.data.top(30)) - (lotsdataview.data.top(20))))"> </div> <!-- 21 - 30 ?? -->

My question is how do you want to specify which records to show? how do you pass record from 10 to 13? Is it using some menu? Url param? Button?
How do you specify this on the page? Or will it be hardcoded value?

Lost in translation …

Ok i query a database with say 10000.

I then add server connect to the page.
Then DataView to bring in the serverconnect 1
Then use a repeat to only show the records i want to display.
Sorry if i have this all wrong…

my approach is then wrong?

You still have not answered my question. How will you or your user select which records exactly to display? Will you provide some menu for your users? Or should these values be just hardcoded on the page?

I was trying something like this… to select top 10 to 13 records… but im sure it does not work like that :slight_smile:
w4

So you just want to setup your site to always show records 10-13?

You could probably do .top(13).reverse().top(3)

mm yes … sorry if i over confused the question… long day…

cool ill give that a go… thank you

1 Like

I won’t do it like that - returning 1000 records and then load them using data view.
Better set up a paged query, set the limit to 13:

Then on the page, use the paged query as a source for the repeater and add last(3) formatter:

No need of data view here, as you will return 13 recods.
Playing with limit and offset you can do whatever you like.

2 Likes

Thank you Teodor… that is then the correct way,… thank you once again

Agreed, it’s always best to query and return the data you need rather than excessive records.

@Teodor - Just a thought, could you not set limit 3 and offset 10? and have no further manipulation to do?

1 Like

Even better, you can set limit to 3 and offset to 10, this will return the records from 10 to 13:

EDIT: yes @bpj we posted at the same time :slight_smile:

2 Likes

Ha ha - great minds…

2 Likes

just to let you know… this also worked… .top(10).last(5)