Jump to content

help me clean query


Jaynesh

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/241667-help-me-clean-query/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/241667-help-me-clean-query/#findComment-1242492
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.