David Ramsden wrote:
> Hugo Mills wrote:
>> On Wed, Aug 22, 2007 at 12:59:59PM +0100, David Ramsden wrote:
>>> Initially I thought the following SQL statement would work:
>>>
>>> SELECT COUNT(accesslog.url) AS requests, COUNT(deniedlog.url) AS denied
>>> FROM accesslog, deniedlog;
>>>
>>> But this gives me:
>>>
>>> +----------+--------+
>>> | requests | denied |
>>> +----------+--------+
>>> | 117500 | 117500 |
>>> +----------+--------+
>>> 1 row in set (0.00 sec)
>> As pointed out, this is the full cross product -- the database
>> generates a row for each pair of (row from accesslog, row from
>> deniedlog), and then performs the count on those.
>
> Thanks for all the replies. I didn't know how SQL treated that
> statement. I've done some research and have a better understanding.
>
This may be too late, but how about this:
select count(accesslog.url) as requests,
(select count(deniedlog.url) from deniedlog) as denied
from accesslog;
It works for me on a test database.
cheers
Chris
--
Chris Dennis cgdennis@???
Fordingbridge, Hampshire, UK