[nycphp-talk] MySQL: count()children on 2 related tables in 1 query
Rob Marscher
rmarscher at beaffinitive.com
Tue Jan 4 19:17:21 EST 2011
On Jan 4, 2011, at 4:50 PM, Dan Cech wrote:
> Rob,
>
> This is demonstrating 2 special cases which will work properly:
>
> 1. no rows for a parent in one of the child tables
> 2. 1 row for a parent in both child tables
>
> If you run your child inserts again to create more rows you'll end up with a count of 4 instead of 2 in the 3rd row.
Ah yes... there it is. I knew there was a reason I don't remember doing two counts in one query before. Thanks for the free lesson! ;)
More information about the talk
mailing list