mysql - Text and dates in same table. Order so that text is always on bottom -
i have table dates, in same table have text entries. example:
2014-11-02 2014-11-01 not done 2014-10-05 not done not done
if run select * table order dates get
2014-10-05 2014-11-01 2014-11-02 not done not done not done
which perfect. when reverse query using desc get:
not done not done not done 2014-11-02 2014-11-01 2014-10-05
what "not done" on bottom. if got clue :)
the next simple way want:
order (left(dates, 4) + 0 > 0) desc, dates
it converts first 4 digits number. if number greater zero, assumes year , puts rows first. doesn't check formed date, sufficient purposes.
mysql syntax order
No comments:
Post a Comment