tags:

views:

20

answers:

1

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

+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
thank you very much its worked fine (outer join)
moustafa