List:General Discussion« Previous MessageNext Message »
From:Patrick Aljord Date:May 5 2008 2:37am
Subject:Re: why does left join gives more results?
View as plain text  
>  Your doing a left join which can increase the number of rows returned.
>  This is then GROUP BYed and run through a HAVING. Is:
>  posts.poster_id=users.id
>  a one to one relationship? If it is not, then count(*) would be a
>  larger number and pass the HAVING. This may not be your problem, but I
>  suggest you have more than you realize.

this is not a one-to-one as a user can make many comments but a
comment belongs to one user only, so I guess the left join returns
more than necesary. but I'm kind of stuck on that one :/

>  I suggest reading
>  http://www.xaprb.com/blog/2006/04/26/sql-coding-standards/

I read it thanks but I still can't find a way to do it right, I mean I
am following this pattern right no?:

  select column ...
    from table ...
   where criterion ...
group by groupingclause ...
  having havingclause ...
order by orderingclause ...

Thanks in advance

Pat
Thread
why does left join gives more results?Patrick Aljord4 May 2008
  • Re: why does left join gives more results?Rob Wultsch4 May 2008
    • Re: why does left join gives more results?Patrick Aljord5 May 2008
      • Re: why does left join gives more results?Rob Wultsch5 May 2008
  • Re: why does left join gives more results?Brent Baisley5 May 2008