On Fri, Jun 14, 2013 at 7:31 AM, Dave Howorth <dhowo...@mrc-lmb.cam.ac.uk>wrote:

> 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?
>

I think you'd want to do a left outer join where cd's primary key is null.

SELECT *
FROM artist
LEFT OUTER JOIN cd
ON artist.artistid = cd.artist
WHERE cd.cdid IS NULL

-- 
*Ronald J Kimball*
Senior Developer
 - www.snapapp.com | Facebook <http://www.facebook.com/snapapp> *|*
Twitter<http://www.twitter.com/snap_app>
_______________________________________________
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

Reply via email to