[Dbix-class] Right join
Matt S Trout
dbix-class at trout.me.uk
Fri Jan 27 14:37:53 CET 2006
On Fri, Jan 27, 2006 at 11:51:14AM +0100, TAPO (Thomas Agersten Poulsen) wrote:
> Dear list,
>
> Please excuse a possibly stupid question---I might be doing this all backwards.
>
> I am doing a JOIN using DBIx::Class version 0.04999_04
> to find the number of "requestedseqs" that has a "response":
>
> $req->requestedseq()->search({},{join=>'response'})->count()
$req->requestedseq()->search_related('response')->count()
should, I think, do what you mean.
> Here, requestedseq() returns a result-set on a table that has a has_many relation on the "response" table.
>
> Setting DBIX_CLASS_STORAGE_DBI_DEBUG=1
> I get
>
> SELECT COUNT( * ) FROM requested_seqs me LEFT JOIN responses response ON ( response.requested_sequence = me.id ) WHERE ( ( ( request = ? ) ) ): 95
>
> This gives me the number of elements in the requestedseq result-set, and that is not what I want.
>
> The problem would be solved if I could change the "LEFT JOIN" to a "RIGHT JOIN" (or just a "JOIN") or put a "response.id IS NOT NULL" in the WHERE clause.
>
> I anybody can give me a hint, I'll be most grateful!.
>
> Best regards
> Thomas
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list