[This post is an archive from the old SQL Yoga forums]
I have a table with noncontiguous integer values where I wish to return the row which has a value just less than my query.
i.e. if the rows had the following values: 1,3,6,9,12,17 and I queried on 8 I want to get back the row with the value 6.
I thus used a search on a GREATER OR EQUAL TO match, ordered the results and limited them to a single row.
However I need to order the results DESCENDING.
This orders the results -> sqlquery_set theQueryA,"order by", "nav_id"
But how do I specify DESC as the sort?
James
How do I specify the sort order?
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
How do I specify the sort order?
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: How do I specify the sort order?
You should just be able to specify it in the "order by" property.
Code: Select all
sqlquery_set theQueryA,"order by", "nav_id DESC"
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: How do I specify the sort order?
Ah. Perhaps the API could mention this. It currently just says the "order by" property only includes the fields to order by, nothing about being able to specify sort order. As it is (given I tend to ask questions on the weekend) I used rev's db calls to do it. I was sort of close though. I tried: sqlQuery_set theQueryA, "order by", "row_id" "DESC" For some reason I didn't think to include both the field and the sort order as a single string.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder