ORDER BY column ASC but...
Posted: Wed Jan 30, 2008 1:41 pm
Here is my query:
[sql]SELECT * FROM $table ORDER BY $column $direction LIMIT $offset, $count[/sql]
My $table has a field in it called time which is how the table above is usually sorted. Everything works, except that I am trying to order the oldest records first, basically implementing a FIFO (first in, first out) stack. However easy this, I *also* need to have any records with a timestamp of ZERO to be pushed to the bottom as that indicates lowest priority and shouldn't be pushed to the top of the stack even though technically, they are the oldest records...
Make sense? Can it be done while still showing all the records? Do I have to use sub-queries - hopefully there is another technique.
[sql]SELECT * FROM $table ORDER BY $column $direction LIMIT $offset, $count[/sql]
My $table has a field in it called time which is how the table above is usually sorted. Everything works, except that I am trying to order the oldest records first, basically implementing a FIFO (first in, first out) stack. However easy this, I *also* need to have any records with a timestamp of ZERO to be pushed to the bottom as that indicates lowest priority and shouldn't be pushed to the top of the stack even though technically, they are the oldest records...
Make sense? Can it be done while still showing all the records? Do I have to use sub-queries - hopefully there is another technique.