Apache itself does not include tools for logging to databases, but a few third-party scripts and modules are available:
mod_log_sql allows you to log requests directly to a MySQL database: http://www.outoforder.cc/projects/apache/mod_log_sql/
You can then query the database using the Apache LogView SQL tool: http://freshmeat.net/projects/apachelogviewsql/
pglogd collects logs and stores log entries in a PostgreSQL database: http://www.digitalstratum.com/pglogd/.