ryel01 Posted January 17, 2011 Share Posted January 17, 2011 hello! does anyone know how to structure an sql statement to order selected results by category name (catname) alphabetically, but any starting with "other%" always appear last? regan Quote Link to comment https://forums.phpfreaks.com/topic/224667-order-by-category-name-but-other-is-always-last/ Share on other sites More sharing options...
trq Posted January 17, 2011 Share Posted January 17, 2011 You would need to use two separate queries. Quote Link to comment https://forums.phpfreaks.com/topic/224667-order-by-category-name-but-other-is-always-last/#findComment-1160519 Share on other sites More sharing options...
ryel01 Posted January 17, 2011 Author Share Posted January 17, 2011 This seems to work... order by name like "Other%" asc ,name not like "Other%" asc Quote Link to comment https://forums.phpfreaks.com/topic/224667-order-by-category-name-but-other-is-always-last/#findComment-1160972 Share on other sites More sharing options...
ryel01 Posted January 17, 2011 Author Share Posted January 17, 2011 This seems to work... order by name like "Other%" asc ,name not like "Other%" asc Actually no, that didn't work. But this does... order by case when lower(cat_name) like 'other%' then 'zzzzz' else cat_name end Quote Link to comment https://forums.phpfreaks.com/topic/224667-order-by-category-name-but-other-is-always-last/#findComment-1161008 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.