2010-06-18 58 views
0

在我的表中,有一个名为time的列。MySQL order by varchar

字段类型为varchar,价值就像是HH:MM,02-25,21-42,07-15

如何通过递减做排序?

+0

什么是你想实现什么?通常,如果您想按某个字符串对表格进行排序,而且您没有按字母数字或字典顺序排序,则感兴趣的值应存储在单独的字段中。 – 2010-06-18 07:31:02

+0

是否有可能,我有两个领域的日期,时间, 在一个查询我想设置两个ORDER BY子句, 在一个字段作为递减,另一个为ASC, 例如ORDER BY日期,时间DESC这是通用查询,是否有可能是像ORDER BY日期ASC,时间DESC – Bharanikumar 2010-06-18 07:38:55

回答

1
select * from table_name order by column_name DESC; 

其中,

table_name is name of table and 
column_name is name of column in the table (independent of whatever the data-type) 

注: - for proper o/p Your datatype for the time column should be datetime

0

的问题是固定的:

ORDER BY CreationDate ASC,CreationTime DESC