Re: "COUNT() returns 0 if there were no matching rows." .... really?!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Here's an example (snip) from a var_dump of that $BuildPerUniqueDateArray:
> (note that the 'aweber_7solar_aw' table does NOT have a record for the
> date '2009-07-28', so I would expect to see that "1" to be a "0" there.)

If a table doesn't have a record for a given date, I wouldn't expect to see "1"
or "0" -- I would expect not to see any row at all for that date/table
combination. You're not looping through all possible dates, you're looping
through the result-set of your query.

Are you sure that the table in question doesn't have any 2009-07-28 records?

You could add the following column to each SELECT to help troubleshoot:

   GROUP_CONCAT(<date_column>) AS `all_timestamps_for_date`

This will give your result-set an additional column, which will contain a
comma-separated list of all the records that GROUP BY is gathering together in
each row (and therefore all the records that COUNT() is counting).

I'm wondering if some sort of timezone discrepancy is maybe causing a timestamp
record to be attributed to 2009-07-28 unexpectedly.

Ben

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux