我正在尝试执行此查询,但它无法正常工作。
SELECT *
FROM posts P
LEFT JOIN post_status PS ON PS.post_id = P.post_id
LEFT JOIN users U ON U.user_id = P.post_author
WHERE
P.post_cat = '5'
AND P.is_hide = '0'
ORDER BY post_views DESC
LIMIT 8
我想过滤那些“is_hide”字段为0的帖子,但它也会显示值为is_hide = 1的结果。 哪里有问题..
答案 0 :(得分:0)
您的查询似乎缺少where
子句。
SELECT *
FROM posts P
LEFT JOIN post_status PS ON PS.post_id = P.post_id
LEFT JOIN users U ON U.user_id = P.post_author
WHERE P.post_cat = 5
AND P.is_hide = 0
ORDER BY post_views DESC
LIMIT 8
此外,除此之外,如果这些是整数列,您应该直接比较而不是单引号。