You might look at Class::DBI::Sweet (look for the 'Automatic joins for search and count' line in the POD) or the experimental DBIx::Class. The second one is meant to be a replacement for Class::DBI with lots of nice features, but I feel it will take time until it will be usefull for production.