[Dbix-class] Re: how to find rows that have 0 many-to-many rel's
A. Pagaltzis
pagaltzis at gmx.de
Sun Jun 24 13:18:02 GMT 2007
* Matt S Trout <dbix-class at trout.me.uk> [2007-06-21 19:55]:
> On Thu, Jun 21, 2007 at 10:09:40AM +0200, Daniel McBrearty wrote:
> > If I have two tables, say A and B, that have a many-to-many
> > relationship, implemented in the usual way with a join table
> > A_B - how can I economically find rows in table A whose id's
> > are not in A_B at all (i.e. they have zero instances of B
> > associated)?
>
> group_by => 'a_b.a_id', having => \"COUNT(a_b.a_id) = 0"
>
> ?
NB.: in SQL I’d use a straightforward subselect for that:
SELECT x,y,z FROM a WHERE a.id NOT IN (SELECT a_id FROM a_b)
Is that expressible in DBIC?
Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Dbix-class
mailing list