UnknownPlayer Posted December 3, 2010 Share Posted December 3, 2010 Here is question: i have db articles and categories. Now at categories i have: - id - name - info and at articles there are: - id - cat_id - name - description - date Now i wonna get all articles like "SELECT * FROM articles", but i wonna order it by categories name, how can i do that? Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/ Share on other sites More sharing options...
BlueSkyIS Posted December 3, 2010 Share Posted December 3, 2010 SELECT A.* FROM articles A, categories B WHERE A.cat_id = B.id ORDER BY B. name Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142770 Share on other sites More sharing options...
UnknownPlayer Posted December 4, 2010 Author Share Posted December 4, 2010 What is A and B ? :S Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142901 Share on other sites More sharing options...
BlueSkyIS Posted December 4, 2010 Share Posted December 4, 2010 http://www.brainbell.com/tutorials/MySQL/Using_Table_Aliases.htm Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142907 Share on other sites More sharing options...
BlueSkyIS Posted December 4, 2010 Share Posted December 4, 2010 I had a bad space before .name. should be SELECT A.* FROM articles A, categories B WHERE A.cat_id = B.id ORDER BY B.name Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142909 Share on other sites More sharing options...
UnknownPlayer Posted December 4, 2010 Author Share Posted December 4, 2010 Hmm do i need to put "AS" somewhere? Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142927 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2010 Share Posted December 4, 2010 'AS' is optional. Did you even try the query that was posted? Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1142928 Share on other sites More sharing options...
UnknownPlayer Posted December 5, 2010 Author Share Posted December 5, 2010 No i didn't but i will now.. Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1143052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.