After getting data from MySQL, how to make the data sequence

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

After getting data from MySQL, how to make the data sequence

Post by ECNU4271 » Sun Sep 01, 2013 1:48 am

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: After getting data from MySQL, how to make the data sequ

Post by dunbarx » Sun Sep 01, 2013 2:19 am

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

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: After getting data from MySQL, how to make the data sequ

Post by ECNU4271 » Sun Sep 01, 2013 3:10 am

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: After getting data from MySQL, how to make the data sequ

Post by dunbarx » Sun Sep 01, 2013 3:56 am

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

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: After getting data from MySQL, how to make the data sequ

Post by ECNU4271 » Sun Sep 01, 2013 4:06 am

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 :D

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: After getting data from MySQL, how to make the data sequ

Post by bangkok » Sun Sep 01, 2013 12:04 pm

There is another solution : to give the work to MySQL
:)

You can sort results in the SQL select query.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: After getting data from MySQL, how to make the data sequ

Post by MaxV » Mon Sep 02, 2013 11:42 am

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 
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply