468,134 Members | 1,261 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,134 developers. It's quick & easy.

selecting in reverse order

I am doing a simple query like col1, col2, date, col4 from table1.
All four colums are of type blob. For date column, I store a string
like this:

Fri Feb 13 11:01:24 2004

I store records as they come in so the oldest record is at the top of
the table. When I select and display, I want to display them in
reverse order (newest record at the top) but I can't sort on date with
strings like that.

Is there any way to do this w/o changing my column types or creating a
temporary table? I guess I can store all the rows temporarily in a
variable and print them out in reverse order but that's not an option.
I am looking a SQL way to accomplish this. Thanks.

-James
Jul 19 '05 #1
3 2432
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #2
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #3
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by R. Rajesh Jeba Anbiah | last post: by
14 posts views Thread by ford_desperado | last post: by
6 posts views Thread by Zri Man | last post: by
20 posts views Thread by sahukar praveen | last post: by
19 posts views Thread by RAJASEKHAR KONDABALA | last post: by
10 posts views Thread by aatish19 | last post: by
20 posts views Thread by mike7411 | last post: by
40 posts views Thread by KG | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.