Select all records don't meet certain conditions in a joined table

后端 未结 2 1824
慢半拍i
慢半拍i 2020-12-22 01:41

Let\'s say we have two tables here , posts and comments, the relations is one to many, there has a field call comment_date in the comments table.

Now I am struggle t

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 02:34

    SELECT *
    FROM posts p
    WHERE NOT EXISTS(
        SELECT 1
        FROM comments c
        WHERE c.comment_date >= 'deadline'
        AND p.post_id = c.post_id
    )
    

提交回复
热议问题