in reply to Re^3: Catalyst, DBIx::Class, SELECT DISTINCT and TT
in thread Catalyst, DBIx::Class, SELECT DISTINCT and TT
generates this SQL, featuring a GROUP BY:$c->model('Database1')->resultset('Table1')->search( undef, { select => ['group'], distinct => 1, order_by => ['group'] }, )
For me, this feels strange. WrittingSELECT group FROM table1 me GROUP BY group ORDER BY group
in the query adds a GROUP BY statement. I just found the semantics of 'distinct' in the DBIx::Class::ResultSet documentation but, still, this is counter-intuitive in my opinion. So, thanks for pointing this out... ;-)distinct => 1
generates this SQL:$c->model('Database1')->resultset('Table1')->search( undef, { select => [ { distinct => 'group' }, ], as => 'group', order_by => ['group'] }, )
This second code is more like what I was looking for... Apparently the trick was to add aSELECT DISTINCT( group ) FROM table1 me ORDER BY group
clause in the query...as => '...'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Catalyst, DBIx::Class, SELECT DISTINCT and TT
by CountZero (Bishop) on Apr 16, 2009 at 14:38 UTC |