[Dbix-class] LEFT OUT JOIN with custom condition/bind value

Hailin Hu i at h2l.name
Sun Nov 25 14:57:28 GMT 2012

Hi, Sven

I'm afraid it is hard to define a conditional relationship with DBIx::Class.
But you can rewrite the condition in JOIN clause with WHERE clause in
most of cases.

SELECT u.email, u.name FROM Users u
LEFT OUTER JOIN Groups g ON u.id = g.uid

Or you can have a look at VIEW approach.

On Sun, Nov 25, 2012 at 12:26 AM, Sven Eppler <sven at sveneppler.de> wrote:
> Hi There,
> i've been searching all along the internet.
> So this List is my last resort. ;)
> I'v got Users in Groups. Now i want to eMail all Users not in Group
> "Admins". So i need something similar like this:
> SELECT u.email, u.name FROM Users u
> LEFT OUTER JOIN Groups g ON u.id = g.uid AND g.id = ADMIN-GROUP-ID
> After searching around this COULD easily be done with a relationship,
> beside the problem, that you cannot give in the custom-group id. So i
> could only create a relationship like "all_users_not_in_admingroup" but
> can't create a general relationsship like "all_users_not_in_groupX"?
> Any ideas on how to solve this problem with DBIC?
> I know about the CODEREF-Option for defining Relationship-Conditions.
> But they don't seem to solve my problem, right?
> Greetings,
> Sven
> _______________________________________________
> 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

More information about the DBIx-Class mailing list