sorting - MySQL Sort by two columns and the sort remaining records alphabetically -
i have 3 three columns in mysql table:
title, featured, sort_order where title varchar, featured enum ("yes" or "no") , sort_order int.
i return result set featured "yes" first , sort featured "yes" sort_order ascending (so, 0, 1, 2, 3, etc...) , then sort remaining records title asc (alphabetical).
i've around @ group by, etc. having issues finding answer.
hopefully i'm trying accomplish makes sense. appreciated :)
you mean this?
select *, if(featured = 'yes', 0, 1) ftsort, cast(if(featured = 'yes', sort_oder, title) char) nosort table order ftsort asc, nosort asc
Comments
Post a Comment