By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,333 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,333 IT Pros & Developers. It's quick & easy.

selecting in reverse order

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.