Page 1 of 1
After getting data from MySQL, how to make the data sequence
Posted: Sun Sep 01, 2013 1:48 am
by ECNU4271
For example,
Table:
Time
0900
1000
0800
0700
I want it to look like :
Time
0700
0800
0900
1000
when the data shows in the field.
How to make that happen in LiveCode?
Thanks!!
Michael
Re: After getting data from MySQL, how to make the data sequ
Posted: Sun Sep 01, 2013 2:19 am
by dunbarx
Hi.
Just sort the data following the title:
sort yourData numeric.
I assume you can separate the two portions of the returned data. I also assume there is more to this than I think.
Craig Newman
Re: After getting data from MySQL, how to make the data sequ
Posted: Sun Sep 01, 2013 3:10 am
by ECNU4271
Great, Craig, thanks!
I tried and it worked fine. Seems if there are several columns, the default setting is to go "numeric" by the first one. But that's fine for me.
Michael
Re: After getting data from MySQL, how to make the data sequ
Posted: Sun Sep 01, 2013 3:56 am
by dunbarx
Glad it worked.
I suspect from your reply that you might want to experiment with sorting using an undocumented feature of LiveCode, that is, multiple stable sorting.
The method is:
sort container by sortKey1 & sortKey2 & sortKey3...
If you have a table that is tab and return delimited, you could (pseudoCode):
set the itemdelimiter to tab
sort yourTableData by item 1 & item 2 & item 3...
The natural order of the sort would be by lines, and you might find this more compact when dealing with your column data.
I wish it were possible to modify the sortKeys independently, so that you could sort, say, item 1 numeric & item 2 text & item 3 dateTime, etc. But this is not possible.
Craig
Re: After getting data from MySQL, how to make the data sequ
Posted: Sun Sep 01, 2013 4:06 am
by ECNU4271
Aha, Craig
It's really good to know that way of sorting orders.
But the simple "sort data numeric" has met my needs so I'd just stick to it
Thanks anyway, maybe later when I need that complicated way to sort information into the field, I'll look into the codes.
Best regards,
Michael
Re: After getting data from MySQL, how to make the data sequ
Posted: Sun Sep 01, 2013 12:04 pm
by bangkok
There is another solution : to give the work to MySQL
You can sort results in the SQL select query.
Re: After getting data from MySQL, how to make the data sequ
Posted: Mon Sep 02, 2013 11:42 am
by MaxV
bangkok wrote:There is another solution : to give the work to MySQL
You can sort results in the SQL select query.
Exactly, try SQL code like:
Code: Select all
SELECT time FROM mytable ORDER BY time
To obtain reverse order
Code: Select all
SELECT time FROM mytable ORDER BY time DESC