whiteboikyle Posted August 9, 2011 Share Posted August 9, 2011 So i have a DB with a table in called 'friends' and in the table i have userID and FriendID, thus finding all the friends you would look up userID and display all of them.. If i have 5 friends and their names are Kyle, Joe, Bob, Dillion, and Josh. When i go to look up my friends i want to know how to sort all those names alphabetically Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/ Share on other sites More sharing options...
Maq Posted August 9, 2011 Share Posted August 9, 2011 ORDER BY Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1254972 Share on other sites More sharing options...
The Little Guy Posted August 9, 2011 Share Posted August 9, 2011 select * from friends f left join members m on(f.friendID = m.userID) where f.userID = 12345 order by m.firstName; Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1254984 Share on other sites More sharing options...
whiteboikyle Posted August 9, 2011 Author Share Posted August 9, 2011 ORDER BY LOL at you not listening/reading correctly. select * from friends f left join members m on(f.friendID = m.userID) where f.userID = 12345 order by m.firstName; Can you explain to me in depth a little.. I think i understand what your doing but dont know how to implement that Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1254985 Share on other sites More sharing options...
Maq Posted August 9, 2011 Share Posted August 9, 2011 Listen whiteboy, I saw your other thread and you convey a sense of denseness. That IS what you need. A few pieces of advice; when making a thread, ask a question. Your OP does a very poor job trying to describe your issue. You obviously didn't even attempt to try this yourself, a simple Google search would get you well on your way. Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1254987 Share on other sites More sharing options...
premiso Posted August 9, 2011 Share Posted August 9, 2011 ORDER BY LOL at you not listening/reading correctly. You tell him girl! Teach that Maq who is boss. mmmhmmm because we all know there is nothing on the in between side of things mmhmmm. Thats how us whiteboi girls rolls you know what I am sayin to ya? mmmhmmm. Cause we always know how to read and listen mmhmmm so just tell him to talk to the hand as our faces ain't listenin (snaps fingers in a circular direction). mmhmmmmm Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255007 Share on other sites More sharing options...
broseph Posted August 9, 2011 Share Posted August 9, 2011 Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255010 Share on other sites More sharing options...
whiteboikyle Posted August 9, 2011 Author Share Posted August 9, 2011 Listen whiteboy, I saw your other thread and you convey a sense of denseness. That IS what you need. A few pieces of advice; when making a thread, ask a question. Your OP does a very poor job trying to describe your issue. You obviously didn't even attempt to try this yourself, a simple Google search would get you well on your way. I did a google search.. I explain in the best way possible.. its a table that has a userid and a friendid.. Thats it... How would orderby order a users name that is on a completely different table. I have more knowledge in PHP then CSS thus i would know the 'orderby'. If you were the OP and i replied with that you would of said the same thing. I didnt any way disrespect you nor anyone else. Now premiso on the other hand is... And i did do a google search.. Couldnt find what i was looking for, so posting was clearly a suitable reasoning. and clearly you can see my frustration when posting on here im getting answers that aren't to my understanding, especially on the CSS thread. Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255013 Share on other sites More sharing options...
whiteboikyle Posted August 9, 2011 Author Share Posted August 9, 2011 so the table ___friend_____ --userID-- --friendID-- ________________ _____________users______________ --ID -- --name-- --username-- --password-- _______________________________ a foreach within a foreach would work but im not sure how to save all data to an array then sort that array by name then echo, but thats not a very good way of doing it.. seems fairly slow.. I am pretty sure the way the user 'the_little_guy' said it would make sense.. Just never seen that done, and a little more info would help.. Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255018 Share on other sites More sharing options...
The Little Guy Posted August 9, 2011 Share Posted August 9, 2011 A left join takes table A (as your main table) then joins table B (as your secondary table) to make one final table as the result. the "ON" construct is like a where, the difference is (for this example), it is taking a field from A and matching it with a field from table B to make one row, after all the matches are found it will give you your resulting table set. the "WHERE" is performed before the "ON" Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255023 Share on other sites More sharing options...
whiteboikyle Posted August 9, 2011 Author Share Posted August 9, 2011 A left join takes table A (as your main table) then joins table B (as your secondary table) to make one final table as the result. the "ON" construct is like a where, the difference is (for this example), it is taking a field from A and matching it with a field from table B to make one row, after all the matches are found it will give you your resulting table set. the "WHERE" is performed before the "ON" WOW that simple.. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/244340-friends-sorted-alpha/#findComment-1255028 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.