http://www.perlmonks.org?node_id=316880


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