[Dbix-class] Help with Problem with Distinct
Matt Lawrence
matt.lawrence at ymogen.net
Wed Feb 20 11:02:13 GMT 2008
Neil Lunn wrote:
> >
> >
> > neil.lunn wrote
> >>
> >> I write the following structure in full. The problem I am having is
> >> that any other combination of 'distinct' as shown in the commented
> parts
> >> throws an error. What am I missing?
>
> Okay, I'll put that down to a misunderstanding of the man page as I
> can clearly see that
> 'select' => [ { distinct => [ 'm2.inventorycategoryid', 'c2.name' ] }
>
> will produce:
>
> select distinct (m2.inventorycategoryid, c2.name)
>
> Which of course is not valid SQL as this is not one column
>
> this can be fixed again by referencing:
>
> select => [ \"distinct m2.inventoryitemid, c2.name"]
>
You can pass distinct => 1 to the attributes to affect a GROUP BY clause
containing all columns, which should be logically equivalent to SELECT
DISTINCT
{
select => [ 'm2.inventorycategoryid', 'c2.name' ],
distinct => 1,
}
Matt
More information about the DBIx-Class
mailing list