select posts.id, comments.id, count(comments.id) as commentscount from
posts, comments where comments.posts_id = posts.id where commentscount = 0
group by posts.id;

Right?

Eric


On 2/13/07, Sergei <[EMAIL PROTECTED]> wrote:
>
>
> No, this is not useless. Yes, there is a COUNT function. But you
> cannot COUNT comments of many posts without subquery. And subqueries
> are quite slow.
>
> for example:
>
> SELECT Posts.id FROM Posts WHERE (SELECT COUNT(Comments.id) FROM
> Comments WHERE Comments.post_id=Post.id) = 0
>
> It's very slow, because it has to count every posts' comments.
>
>
> On 13 фев, 16:44, "Eric C Blount" <[EMAIL PROTECTED]> wrote:
> > But that seems useless, just a workaround for the problem. There are
> > count(*) functions in databases for just this purpose, so as not to
> violate
> > Third Normal Form rule of creating databases. There should be an easy
> way to
> > use the count(*) function from Cake.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to