Andy11548 Posted August 17, 2012 Share Posted August 17, 2012 Hello, I could do with some help joining this query in to another query. I'm completely and utterly blagged on what I'm doing now. I need this query: mysql_query("SELECT * FROM `users` WHERE `username`='".$_SESSION[username]."'"); placed into this one: mysql_query(" SELECT f1.cat_name as CatName, f1.cat_id as CatID, f2.cat_id as SubCatID, f2.sub_id as SubID, f2.sub_name as SubName, f2.sub_desc as SubDesc, f3.topic_id as TopicID, f3.user_id as UserTopicID, f3.topic_name as TopicName, f3.topic_message as TopicMessage, f4.user_id as UserReplyID, f5.username as Username, (SELECT COUNT(*) FROM forum_topics as f3 WHERE f3.sub_id = f2.sub_id) as TopicAMT, (SELECT COUNT(*) FROM forum_replies as f4 WHERE f4.topic_id = f3.topic_id) as ReplyAMT FROM `forum_cats` as f1 LEFT JOIN `forum_sub` as f2 ON f1.cat_id = f2.cat_id LEFT JOIN `forum_topics` as f3 ON f2.sub_id = f3.sub_id LEFT JOIN `forum_replies` as f4 ON f3.topic_id = f4.topic_id LEFT JOIN `users` as f5 ON f4.user_id = f5.user_id WHERE f1.cat_id='$cat' $getSub $getTopic ORDER BY f2.sub_id ASC, f4.reply_id DESC "); Help would be appreciated. Thanks, Andy. Quote Link to comment Share on other sites More sharing options...
scootstah Posted August 17, 2012 Share Posted August 17, 2012 ON f4.user_id = f5.user_id AND f5.username = '" . $_SESSION['username'] . "' That should work I think. Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted August 17, 2012 Author Share Posted August 17, 2012 Well, it's give me no errors and the display is all the same. How would I go around using that then? Thanks, Andy. Quote Link to comment Share on other sites More sharing options...
scootstah Posted August 17, 2012 Share Posted August 17, 2012 In addition to my previous reply, try changing LEFT JOIN `users` as f5 to INNER JOIN `users` as f5 Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2012 Share Posted August 20, 2012 That table is already being joined....? Quote Link to comment Share on other sites More sharing options...
jardrake Posted August 22, 2012 Share Posted August 22, 2012 That table is already being joined....? Oh, you crack me up! Why have I never heard of phpFreaks before? So many things missed, and so many to catch up on. Quote Link to comment 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.