christopherbecker Posted November 20, 2012 Share Posted November 20, 2012 Hey guys, This is my first proper php app. so be nice I have a mysql_query that joins a two tables, it's working properly, but I want to add one extra variable with the results. $topRanked = mysql_query("SELECT * FROM news JOIN users ON news.Username = users.Username WHERE users.connected='$yourname' ORDER BY created DESC") or die(mysql_error()); How this works is, I have 2 tables, one containing news stories and one with users...the users can be linked with one another, therefor you see their story. This part works GREAT, but the user doesn't see his own stories. Currenly it's getting every news story, except the users news story...how can I modify the QUERY that it also includes the users news stories? Link to comment https://forums.phpfreaks.com/topic/270936-mysql_query-join-one-extra-variable/ Share on other sites More sharing options...
deoiub Posted November 20, 2012 Share Posted November 20, 2012 Hey guys, This is my first proper php app. so be nice I have a mysql_query that joins a two tables, it's working properly, but I want to add one extra variable with the results. $topRanked = mysql_query("SELECT * FROM news JOIN users ON news.Username = users.Username WHERE users.connected='$yourname' ORDER BY created DESC") or die(mysql_error()); How this works is, I have 2 tables, one containing news stories and one with users...the users can be linked with one another, therefor you see their story. This part works GREAT, but the user doesn't see his own stories. Currenly it's getting every news story, except the users news story...how can I modify the QUERY that it also includes the users news stories? I'm assuming you want to add an OR to your WHERE clause. Currently you are only finding where the users.connected field matches, you probably want to add where the users.Username field also matches. Link to comment https://forums.phpfreaks.com/topic/270936-mysql_query-join-one-extra-variable/#findComment-1393742 Share on other sites More sharing options...
Muddy_Funster Posted November 20, 2012 Share Posted November 20, 2012 Nothing in the query it's self is explicitly excluding the current user from the results returned. Without more information on your tables only speculation can be provided. Link to comment https://forums.phpfreaks.com/topic/270936-mysql_query-join-one-extra-variable/#findComment-1393743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.