violinrocker Posted May 6, 2011 Share Posted May 6, 2011 I wanted to do something like the code below $str = "SELECT news_feed.*, friends.*, articles.* FROM news_feed INNER JOIN articles ON news_feed.name = anime.name OR inner join friends on news_feed.name = friends.friendname WHERE friends.username = '$name' or articles.subscriptor = '$name'"; what its supposed to do is check the tables "articles" and "friends" and check if they are related to the $name (i.e. $name is a friend of $friendname or $name is subscribed to this article) and then get the items from news_feed that $name's friends and the articles he is subscribed to posted Quote Link to comment https://forums.phpfreaks.com/topic/235668-inner-join/ Share on other sites More sharing options...
phppaper Posted May 6, 2011 Share Posted May 6, 2011 you do not need to put "inner join" to join 2 tables together, just select "all the things you want" from tablea a, tableb b where (condition). if you want to join 3 tables with all records, use left join instead Quote Link to comment https://forums.phpfreaks.com/topic/235668-inner-join/#findComment-1211321 Share on other sites More sharing options...
violinrocker Posted May 6, 2011 Author Share Posted May 6, 2011 what I want to do is something like... i want to get rows from the news_feed that my friends and articles i subscribed to posted... but the only way to determine if i am friends with the one who posted or if i am subscribed to that article is checking 2 different tables.... so its sorts like "news_feed INNER JOIN ON friends OR articles" and not joining 3 tables Quote Link to comment https://forums.phpfreaks.com/topic/235668-inner-join/#findComment-1211447 Share on other sites More sharing options...
fenway Posted May 11, 2011 Share Posted May 11, 2011 What was wrong with your initial code? Quote Link to comment https://forums.phpfreaks.com/topic/235668-inner-join/#findComment-1213922 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.