Current location: Hot Scripts Forums » Programming Languages » PHP » Using Perl to sort times in mysql


Using Perl to sort times in mysql

Reply
  #1 (permalink)  
Old 01-01-04, 10:45 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Using Perl to sort times in mysql

Ok, heres the story, I can get MySQL to sort my times, because there an invalid format, so heres the layout of my mysql table

Table: times
|ID|USER|TIME|
1 Joe 01:22:88

Okay, so how do i get perl to select all the times from the TIME rows and sort them, then re-organize the id's in the table to match the order of the times.

understand?

Can someone help me with this
Reply With Quote
  #2 (permalink)  
Old 01-04-04, 04:57 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

It is not Perl but MySQL who should sort the result for you. When you prepare() your query, you should pass an SQL like this:

Code:
SELECT `TIME` FROM times ORDER BY `TIME`
When you excute() this, you will get all the TIME fields' values from times table in ascending order. If descending, you append DESC keyword to the above.

I'm not sure what you wanted to do with the ID, but database tables are not like spreadsheet, and each row is an independent record from others, so you can't sort one column and leave the other columns unchanged (or sorted in another way). I would perhaps get IDs in a separate query and sort it as well, combine them with the sorted TIME side-by-side and put them all into one table to get what I think you wanted.

For more info about MySQL, consult the following:

MySQL Documentation:
http://www.mysql.com/documentation/index.html

For Perl-side of operations (handle retrieved data in a loop, etc), you can go to Perl forum or start with something like here:

http://www.danchan.com/feature/2000/...sql/mysql3.htm

Hope this helps.
__________________
Blavv =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Perl w/ mysql supra Script Requests 0 01-01-04 10:03 AM
New to perl, could use some help Arowana Perl 4 10-24-03 10:49 AM
great product for dumping/recovering MySQL databases Dave Brown General Advertisements 1 10-03-03 07:40 AM
Free PHP, Perl and possible mySQL hosting! toby General Advertisements 8 06-17-03 01:04 AM


All times are GMT -5. The time now is 07:50 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.