我有两个表帖子和评论,我想从特定的 user_id 获取所有没有任何评论的帖子。Posts 表有id、title和content字段,而 comments 表有id、post_id、user_id和comment字段。
在两个表上使用 LEFT JOIN 并在 WHERE 子句中使用不等比较运算符。
SELECT DISTINCT posts.id
FROM posts
LEFT JOIN comments
ON posts.id = comments.post_id
WHERE comments.user_id <> 123
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句