[Catalyst] DBIx::Class - table relations and joins

Hernan Lopes hernanlopes at gmail.com
Tue Dec 14 15:37:47 GMT 2010


Thats DBIx::Class question and not a catalyst question.
here are dbix class docs:
http://search.cpan.org/~frew/DBIx-Class-0.08124/everything you need is
there. Take a look at joining at the bottom of the
page.

--Hernan

On Tue, Dec 14, 2010 at 1:27 PM, Vivek Chhikara <vivek at chhikara.org> wrote:

>
>
> I am new to catalyst and need guidance in fetching some data from my mysql
> db.
>
> I want to know how can I write below queries(1&2)
>
> Here is dummy table structure I am using.
> -------------------------------------------------
>         table1
>         =3D=3D=3D=3D=3D=3D=3D
>         qid  sid status name
>         __PACKAGE__->set_primary_key("qid");
>         __PACKAGE__->belongs_to("queq_dump",
> 'MYAPP::Schema::Result::Table2, {qid =3D> 'qid'});
>
> -------------------------------------------------
>         table2
>         pid eid qid name
>         primary_key =3D=3D pid+qid+eid
> -------------------------------------------------
>
>     QUERY 1
>     =3D=3D=3D=3D=3D=3D=3D
>     select A.qid, A.name, A.name from table1 A, table2 B
>     where
>          A.qid =3D B.qid
>     and  A.sid =3D 1
>     and  B.pid !=3D 2
>
>     QUERY 2
>     =3D=3D=3D=3D=3D=3D=3D
>     select A.qid, A.name, A.name from table1 A, table2 B
>     where
>         A.qid =3D B.qid and B.eid =3D (select min(eid) from table2 where
> table2.status =3D 1)
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101214/28942=
8cd/attachment.htm


More information about the Catalyst mailing list