Jaynesh Posted July 11, 2011 Share Posted July 11, 2011 Can somebody please help me clean this query up using INNER JOIN instead. SELECT dbUsers.id, dbPosts.post, dbUsers.username, dbPosts.post_id, dbPosts.karma_up, dbPosts.karma_down FROM dbPosts, dbUsers, dbFriends WHERE (dbPosts.post_id NOT IN (SELECT post_id FROM dbDownvote WHERE user_id = $user) AND dbPosts.username_id = dbUsers.id AND dbFriends.user_id = $user AND dbFriends.friend_id = dbPosts.username_id AND dbFriends.status = 1 Quote Link to comment Share on other sites More sharing options...
fenway Posted July 13, 2011 Share Posted July 13, 2011 SELECT dbUsers.id, dbPosts.post, dbUsers.username, dbPosts.post_id, dbPosts.karma_up, dbPosts.karma_down FROM dbPosts INNER JOIN dbUsers ON ( dbPosts.username_id = dbUsers.id ) INNER JOIN dbFriends ON ( dbFriends.friend_id = dbPosts.username_id ) LEFT JOIN dbDownvote ON ( dbDownvote .post_id = dbPosts.post_id ) WHERE dbDownvote .post_id IS NULL dbDownvote.user_id = $user AND dbFriends.user_id = $user AND dbFriends.status = 1 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.