There is nothing that will do a good job of generating SQL for complicated outer joins and the like. Class::DBI does a good job of mapping tables to objects and letting you address your data in an OO way. It can generate SQL for simple things like what you show above, and it can take arbitrary SQL and handle to busy-work of fetching the data and turning it into objects that you can work with.
Comment on Re: 'automating' SQL queries, use Class::DBI?
i don't expect there to be a good way of generating everything should of a lot of concatenation ... :-(
and i'm not particularly fond of table --> object mapping ( if it's a one-to-one relationship ). i've already had to deal with a 'home-grown' solution with a previous job that just became unmaintainable, unweildy, slow, and excessively complicated.