Interista Posted October 26, 2012 Share Posted October 26, 2012 Hello, How I can sort MySQL result . I have to two selects box , Sort by alphabetical and sort by the categories , the two selects box in the same page . How I can filter the result according of the sort type . Like sort the result by specific category and in the same time sort it from Z to A . / DESC Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/ Share on other sites More sharing options...
MDCode Posted October 26, 2012 Share Posted October 26, 2012 $sql = "SELECT * FROM `whatever` ORDER BY `category` DESC"; Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388045 Share on other sites More sharing options...
Interista Posted October 26, 2012 Author Share Posted October 26, 2012 $sql = "SELECT * FROM `whatever` ORDER BY `category` DESC"; OK I know that , But How I can sort the result of this query like sort it according the category . the only way use queries ? Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388048 Share on other sites More sharing options...
MDCode Posted October 26, 2012 Share Posted October 26, 2012 ORDER BY `category` DESC Will order it in descending order in the alphabet Sorry but that's all I can figure out by the way you worded it Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388050 Share on other sites More sharing options...
Jessica Posted October 26, 2012 Share Posted October 26, 2012 ORDER BY category DESC, name DESC Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388052 Share on other sites More sharing options...
MDCode Posted October 26, 2012 Share Posted October 26, 2012 ORDER BY category DESC, name DESC Oops, I get what you meant now...sorry Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388053 Share on other sites More sharing options...
Interista Posted October 27, 2012 Author Share Posted October 27, 2012 So that mean there is no way to do it using like functions in jQuery or anything else .. ! so I should make a functions with queries for all sort facilities available . Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388061 Share on other sites More sharing options...
Jessica Posted October 27, 2012 Share Posted October 27, 2012 I just told you how... What are you asking? Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388068 Share on other sites More sharing options...
ManiacDan Posted October 27, 2012 Share Posted October 27, 2012 you can sort data in any programming language on any computer. you really need to be more specific. why is sorting it in the query not sufficient for your needs? Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388072 Share on other sites More sharing options...
Interista Posted October 27, 2012 Author Share Posted October 27, 2012 Sorry for not being clear , But the problems that I face is hard to do it in the query for me . because I want to sort result after filter it according to category type . so as example if I have a 5 rows , and filter it using category type it will be like 3 rows as example . How I can sort only the 3 rows not the whole result of the first query . I hope it's a clear now :$ Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388112 Share on other sites More sharing options...
MDCode Posted October 27, 2012 Share Posted October 27, 2012 Still not very clear to me but you can limit results using LIMIT 3 in your query Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388118 Share on other sites More sharing options...
Jessica Posted October 27, 2012 Share Posted October 27, 2012 WHERE category = 'category' ORDER BY name DESC Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388134 Share on other sites More sharing options...
ManiacDan Posted October 27, 2012 Share Posted October 27, 2012 WHERE category = 'category' ORDER BY name DESC Seriously, sorting and filtering is the reason for SQL's existence. That's what it's for. Link to comment https://forums.phpfreaks.com/topic/269958-sort-mysql-result/#findComment-1388146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.