Author Topic: Sorting a database from two colums ... HELP!!!  (Read 397 times)

Morten Jakobsen

  • New Member
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Sorting a database from two colums ... HELP!!!
« on: August 05, 2010, 09:22:04 AM »

Hi, i got a minor problem .. trying to sort a few things out.
I'm saving a time stamp in my DB, where the hours and minutes are stored in eachh their own row like:
Hours in column: timehh
Minutes in column: timemm


My problem is when i sort it then it's not sorting right ..


The way it sorts now:
08:00
09:00
08:10
08:20
08:05


The way i want it to sort
08:00
08:05
08:10
08:20
09:00


This i my    query:
"SELECT * FROM timedate ORDER BY timehh AND timemm ASC"


Anyone got a quick fix?


I can post source if needed..

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 777
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: Sorting a database from two colums ... HELP!!!
« Reply #1 on: August 05, 2010, 09:30:09 AM »
Here is a quick fix for your query:

"SELECT * FROM timedate ORDER BY timehh, timemm"
Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!

Morten Jakobsen

  • New Member
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Sorting a database from two colums ... HELP!!!
« Reply #2 on: August 06, 2010, 03:54:23 AM »
Here is a quick fix for your query:

"SELECT * FROM timedate ORDER BY timehh, timemm"


thank you  :D