runnerjp Posted October 22, 2009 Share Posted October 22, 2009 ok i have this in my code... <?php SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.Username=friends.friendname) WHERE friends.username='$profilename' GROUP BY friends.friendname ORDER BY RAND() limit 9?> I just want to know how it works?? so what does the . do and is the left one the table and right the colum? Quote Link to comment https://forums.phpfreaks.com/topic/178609-solved-need-help-explaining-the-in-a-query/ Share on other sites More sharing options...
Daniel0 Posted October 22, 2009 Share Posted October 22, 2009 It's just a way of expressing the full name, so friends.friendname is referring to the field called friendname in the table called friends. Quote Link to comment https://forums.phpfreaks.com/topic/178609-solved-need-help-explaining-the-in-a-query/#findComment-942015 Share on other sites More sharing options...
cbolson Posted October 22, 2009 Share Posted October 22, 2009 so what does the . do and is the left one the table and right the colum? Yes, as you are referencing 2 tables with one query, using the "." with the table name (or alias) before the column name tells the query which table to get the column from. If the tables have completely different column names this is not a problem but if they have common names, which is often the case, it needs to know which one to get. Quote Link to comment https://forums.phpfreaks.com/topic/178609-solved-need-help-explaining-the-in-a-query/#findComment-942019 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.