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? Quote 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 Quote 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 Quote 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 Quote 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 Quote 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? Quote 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? Quote 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.. Quote Link to comment https://forums.phpfreaks.com/topic/220610-help-with-ordering/#findComment-1143052 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.