shortysbest Posted March 18, 2011 Share Posted March 18, 2011 I have two mysql tables, one is called "posts", the other is called "removed_posts", I have joined them together and can get some of the information from the tables, but I want to be able to get all of the information. This is my query, and the variables I need the information to go to: $quer = mysql_query("SELECT posts.id, removed_posts.post_id FROM posts, removed_posts WHERE posts.id=removed_posts.post_id AND removed_posts.user_id='".$session."'"); while($get_post = mysql_fetch_array($quer)) { $session = $_COOKIE['id']; $to_id = $get_post['to_id']; $from_id = $get_post['from_id']; $post = linkify(nl2br(htmlentities($get_post['post']))); $date = time_stamp($get_post['date']); $id = $get_post['id']; What that's doing is selecting the id from 'posts' table, and selecting the post_id from the 'removed_posts' table (The query checks to make sure posts.id is equal to removed_posts.post_id), it does that just fine, since I defined what information I wanted it to get in the query, however, now I need to get the other information which will come from the 'posts' table. $get_post['to_id'], $get_post['from_id'], $get_post['post'], and $get_post['date'] I hope that's not toooooo confusing, any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/231035-simple-mysql_query-table-join-help-needed/ Share on other sites More sharing options...
noXstyle Posted March 18, 2011 Share Posted March 18, 2011 How about: "SELECT * FROM posts INNER JOIN removed_posts WHERE posts.id=removed_posts.post_id AND removed_posts.user_id='".$session."'" Link to comment https://forums.phpfreaks.com/topic/231035-simple-mysql_query-table-join-help-needed/#findComment-1189319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.