Hi, Am 14.06.2013 um 13:31 schrieb Dave Howorth:
> My brain is feeling fried and is failing to solve a simple puzzle. > > Using the standard table 'artist' which has a primary key 'artistid'. > > And the other table 'cd' that has a link to artists, via a foreign key > 'artist'. There may be more than one CD associated with a single artistid. > > I want a resultset containing all artists which have NO associated CD. > > What's the appropriate way to select this resultset? one way would be to shrink your resultset with '-not_in'. However, "NOT IN" in SQL is sometimes very inefficient. my $artists_with_cd = $schema->resultset('CD')->get_column('artist')->as_query; my @artists_without_cd = $schema->resultset('Artist')->search( { artistid => { -not_in => $artists_with_cd } } )->all; Best, Wolfgang Kinkeldei -- ' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x '( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+|| ' > ^ < ' .q<!-- Wolfgang Kinkeldei - wolfgang at kinkeldei dot de --> _______________________________________________ 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/dbix-class@lists.scsys.co.uk