0

I have two tables - forum_topics and topics_posts. I want to select rows from forum_topics which have no posts in the topics_posts table, but cannot figure out how to. Does an SQL statement like this exist:

select from * `forum_topics` where have no rows in `topics_posts` 

1 Answer 1

2

I think you want something like that:

select * from forum_topics t where not exists ( select * from topics_posts p where p.topic_id = t.id ); 

Although using an outer join, might be a bit faster than the subquery:

select * from forum_topics t left outer join forum_posts p on t.id = p.topic_id where p.id is null; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.