Previous record based on user input

Options

I need to get the previous users record based on an input.

example: input integer fuel_id = 960

I need to get fuel.id 958

I have tried to use a filter fuel_id subtract 1 but it returns record 959 witch is another users record. I do have athentication enabled

any ideas?

Tagged:

Best Answer

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Answer ✓
    Options

    So the maximum record associated with this individual that is less than the passed fuel_id?

    I would:

    1) add the user id match on the query filter
    2) add the id "less than" on the query filter, with a comparison value of the input (e.g. fuel.id < input:fuel_id)
    3) Go to the output tab
    4) Click the first pencil (about 3/4 down the page)
    5) Add a sort. You'll want to sort by the id field, descending.
    6) Change the type of the result to "single" because you just want the top result.

    Use stop-and-debug to confirm the result of the above is the record you're looking for!

    Fancy data manipulation like this is an area where Xano really shines. It's still complex though, which is why it's part of the "hardest 5%" we work on in our forum and daily office hours at Statechange.ai.

Answers