It is simple, create correct relations and use
$teams_rs->search( {'players3.name' => 'vasya' }, { prefetch => { players =>
{ players => 'players' } } } );On Thu, Nov 12, 2009 at 4:08 PM, Terence Monteiro <[email protected]>wrote: > I have 2 tables, one for soccer teams and one for players. I want to > find the team having players A, B and C. > > Schema::Team has many Schema::Player > > How could I accomplish the above? In SQL, one way would be: > > select teams.* from teams > inner join players p1 on p1.team = team.id > inner join players p2 on p2.team = team.id > inner join players p3 on p3.team = team.id > where p1.name = 'A' > and p2.name = 'B' > and p3.name = 'C'; > > How could I do this using DBIx::Class? > > -- > Regards, Terence. > > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: > http://www.grokbase.com/group/[email protected] >
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
