Sorting on Data Retrieval

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cbarnhart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 48
Joined: Mon May 07, 2012 2:10 pm

Sorting on Data Retrieval

Post by cbarnhart » Wed Jul 24, 2013 2:21 pm

I am trying to sort my data as I grab it from the database. I want to sort the data in Desending order by the field date -
put revQueryDatabase( theConnectionID, "select * from hospaccess.News where Type = 'Market' ORDER BY 'Date' DESC") into theCursor

But the Sort is not working. I am hoping I am making a simple mistake

Any suggestions

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Sorting on Data Retrieval

Post by BvG » Fri Aug 23, 2013 12:33 pm

You are using the database sorting, so this is not really LC specific. Maybe you stored the date field in a non-date format, so the database that you use doesn't understand that it is in fact a date. If you don't want to figure out how to sort stuff in sql, you can always sort the data afterwards in LC, using the "sort" command. But then too, you'll need to watch out to use a date format that is easily sortable (i personally like the seconds for that), so you might also need to loop trough the data and use "convert" for each line.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Sorting on Data Retrieval

Post by phaworth » Tue Oct 29, 2013 11:07 pm

Putting single quotes around Date makes SQL think it's a literal value not a column name.
Pete

Post Reply