-2

MySQLクエリがあります:

SELECT p.* FROM posts p
WHERE 
(
    p.userid in 
    (
        select blogid from abos where userid=11
    )
    OR p.userid = 11
) 
AND NOT EXISTS
(
    SELECT null FROM posts_denied r 
    WHERE r.post_id = p.id AND r.userid = 11
)
order by p.id DESC limit 5

"where in" 句を削除したいのですが...どうすれば最高のパフォーマンスのクエリ構文を見つけることができますか?

4

1 に答える 1

0
SELECT DISTINCT p.*
FROM posts p
JOIN abos a
ON p.userid = a.blogid OR p.userid = 11
LEFT JOIN posts_denied r
ON r.post_id = p.id AND r.userid = 11
WHERE (a.userid = 11 OR p.userid = 11)
  AND r.post_id IS NULL
ORDER BY p.id DESC
LIMIT 5
于 2013-08-09T19:46:49.833 に答える