2010-06-18 75 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