Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Problem with table joins with Class::DBI

by Roy Johnson (Monsignor)
on Dec 24, 2003 at 16:19 UTC ( #316880=note: print w/replies, xml ) Need Help??


in reply to Problem with table joins with Class::DBI

According to perldoc Class::DBI:
Of course, any query can be added via set_sql, including joins. So, to add a query that returns the 10 Artists with the most CDs, you could write (with MySQL):
Music::Artist->set_sql(most_cds => qq{ SELECT artist.id, COUNT(cd.id) AS cds FROM artist, cd WHERE artist.id = cd.artist GROUP BY artist.id ORDER BY cds DESC LIMIT 10 }); my @artists = Music::Artist->search_most_cds();
HTH.

The PerlMonk tr/// Advocate

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://316880]
help
Chatterbox?
[beech]: of course the magic word that explains everything :p
[erix]: they should lean to gnash their teeth a bit instead of writing more ^Re:NN-nodes :)
[erix]: *learn
[erix]: comic relief: how to start a riot and a fortune at the same time
[beech]: :) thats too generous to jdporter, don't start none won't be none -- there is about two decades (rounding up) worth of "ineffective" node titles -- leave the pope alone :p

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2017-01-17 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (159 votes). Check out past polls.