MySQL: Order by time (MM:SS)?

Posted by Shpigford on Stack Overflow See other posts from Stack Overflow or by Shpigford
Published on 2010-05-07T12:58:09Z Indexed on 2010/05/07 13:08 UTC
Read the original article Hit count: 165

Filed under:
|

I'm currently storing various metadata about videos and one of those bits of data is the length of a video.

So if a video is 10 minutes 35 seconds long, it's saved as "10:35" in the database.

But what I'd like to do is retrieve a listing of videos by length (longest first, shortest last).

The problem I'm having is that if a video is "2:56", it's coming up as longest because the number 2 is more than the number 1 in.

So, how can I order data based on that length field so that "10:35" is recognized as being longer than "2:56" (as per my example)?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about time