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 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 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 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? Link to comment https://forums.phpfreaks.com/topic/235668-inner-join/#findComment-1213922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.