in reply to Re^2: DBI, mysql, SELECT with JOIN and field names
in thread DBI, mysql, SELECT with JOIN and field names

Just a simple idea (taking that your field names contain no underscores (for bravity, you can change this approach to fit your task)):
my %AS = ( requests_id => 'requests.id AS requests_id', requests_name => 'requests.name AS requests_name', requests_rating => '(select count(*) from ratings where ....) AS requ +ests_rating', ...etc... ); my $sth = $dbh->prepare( qq|SELECT $AS{request_id}, $AS{request_name}, $AS{request_rating}, ...etc );

This also allows expand your SELECTs in future without touching code logic.