0

I would like to delete all post that do not contain a relation to media.

My select statement looks like this:

select post.*
from post full outer join media m on post.id = m.post_id where m is null;

How would the delete statement look like to delete all entries in the post table that do not have an entry in media?

1 Answer 1

2

Use NOT EXISTS:

delete from post p
    where not exists (select 1 from media m where p.id = m.post_id);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.