[Dbix-class] Joining group of 2 joined tables together

Hailin Hu i at h2l.name
Wed Aug 29 12:47:06 GMT 2012


you can try to define a self-reference has_one relationship on Table
2, and use the relationship in join.
you can't join tables without relationship defined.

On Wed, Aug 29, 2012 at 5:57 PM,  <tuco at pasteur.fr> wrote:
> Hi list,
>
> I am not sure if such complex join has been asked on the list, but I did not
> find a similar problem in the archive.
> Here are my tables
>
> Table1       Table2
> fid (pk)     srcfid(pk)
> name         fid(fk) <- references Table1.fid
>              start
>              stop
>
> The SQL query I'd like to translate with DBIx is the following
>
> SELECT * FROM Table1 nt1, Table2 nt2, Table 1 mt1, Table2 mt2
> WHERE nt1.fid=nt2.fid AND mt1.fid=mt2.fid AND mt2.srcfid=nt2.srcfid
> ..... other where conditions.
>
> So my question is, does someone would know how to translate the particular
> WHERE clause (mt2.srcfid=nt2.srcfid) ?
>
> Thanks in advance for any clue.
> If this is not possible, I'll move to literal SQL using $dbh and $sth.
>
> Regards
> Emmanuel
>
> --
> -------------------------
> Emmanuel Quevillon
> tuco at_ pasteur dot fr
> -------------------------
>
>
> _______________________________________________
> 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