Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: DBI, mysql, SELECT with JOIN and field names

by maard (Pilgrim)
on Feb 14, 2005 at 10:56 UTC ( [id://430744]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://430744]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-24 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found