If you already have a VARCHAR date, I suggest you reorganize this into a TIME column. This can be easily done online:
UPDATE tablename SET login_time = STR_TO_DATE(login_time, '%l:%i %p'); ALTER TABLE tablename CHANGE login_time login_time TIME;
I am using the TIME type here, since your data apparently only contains time. Maybe a DATETIME type would be most appropriate. See http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.html for various parameters.
In any case, as soon as the column is reorganized to the appropriate type, you can write:
SELECT login_time FROM tablename ORDER BY login_time
With the added benefit, you can now create an index on login_time to speed up searching / sorting:
ALTER TABLE tablename ADD INDEX ( login_time );
See http://sqlfiddle.com/#!2/03991/1 (click "View Execution Plan" to see that the actual index has been used).
source share