i have forum_topics
table and have topics_posts
table
now i want to select from forum_topics
where have no posts from topics_posts
can any one give me the one syntax like this
selct from * forum_topics
where have no rows in topics_posts
table
views:
20answers:
1
+1
A:
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;
tux21b
2010-03-17 09:33:55
thank you very much its worked fine (outer join)
moustafa
2010-03-17 10:02:11