[Hampshire] Help with SQL COUNT() statement.

Top Page
Author: David Ramsden
Date:  
To: Hampshire LUG Discussion List
Subject: [Hampshire] Help with SQL COUNT() statement.

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x58461100.hantslug.org.uk.24678': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Wed Aug 22 13:00:03 2007 BST
gpg: using DSA key B15F69BD3454B217
gpg: Can't check signature: No public key
Hi all,

I've got two tables in my database. One called "accesslog" and one
called "deniedlog". They contain information from Squid and squidGuard.
I'm trying to extract the number of requests from the accesslog and the
number of requests from the denied log so I can display some stats.

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)

Which isn't correct because if I use a COUNT() on each of the tables:

SELECT COUNT(url) AS requests FROM accesslog;
+----------+
| requests |

+----------+
|     5875 |

+----------+
1 row in set (0.00 sec)

SELECT COUNT(url) AS denied FROM deniedlog;
+--------+
| denied |

+--------+
|     20 |

+--------+
1 row in set (0.00 sec)


Can anyone help me out? I don't want to execute two seperate statements
if possible.

Regards,
David.
-- 
 .''`.     David Ramsden
: :'  :    http://0wned.it/
`. `'`     PGP key ID: 3454B217 on wwwkeys.eu.pgp.net
  `-  Debian - Because it works (tm).