-1

我可以在这些查询中避免 INNER JOIN 吗?

"SELECT posts.status, posts.reports, posts.post_id, 
        posts.reply_counts, posts.sender, posts.content, 
        posts.image, posts.thumb, posts.date, 
        members.username, members.avatar, members.state 
 FROM posts 
    INNER JOIN members ON posts.sender = members.member_id 
 WHERE posts.parent_id=0 
    AND posts.wall_id=0 
    AND (
          (members.status=".MEMBER_STATUS_ACTIVE." AND 
           posts.reports<".MAX_REPORT_HIDE." 
           AND posts.status=".POST_STATUS_ACTIVE."
          )
         OR 
         ".$bAdmin."=1 
         OR 
           (".$bMod."=1 AND 
             posts.status<>".POST_STATUS_DELETED."
           )
       ) 
    AND posts.private_id=0 
 ORDER BY posts.post_id DESC, posts.date DESC 
 LIMIT ".(($pagenum-1) * PAGINATION).",".PAGINATION.";"


"SELECT posts.status, posts.reports, posts.post_id, posts.reply_counts, 
        posts.sender, posts.content, posts.image, posts.thumb, posts.date, 
        members.username, members.avatar, members.state 
 FROM posts 
    INNER JOIN members ON posts.sender = members.member_id 
    INNER JOIN notifies ON posts.post_id=notifies.post_id 
 WHERE notifies.member_id=".$member_id." AND 
       posts.parent_id=0 AND 
       members.status=".MEMBER_STATUS_ACTIVE." AND 
       posts.reports<".MAX_REPORT_HIDE." AND 
       posts.status=".POST_STATUS_ACTIVE." AND 
       posts.private_id=0 
 ORDER BY posts.last_update DESC, posts.date DESC 
 LIMIT ".(($pagenum-1) * PAGINATION).",".PAGINATION.";"
4

1 回答 1

0

enter image description here

If you need all rows from both table once match exist then you should use inner join.

于 2013-08-19T12:29:26.257 回答