[Dbix-class] Newbie from SQL to DBIx

Will Crawford billcrawford1970 at gmail.com
Thu Mar 8 10:12:59 GMT 2018


A visit to https://www.google.co.uk/search?q=dbix+select+distinct should
answer your question:

DBIx::Class::Manual::Cookbook (first result here) says:

SELECT DISTINCT with multiple columns
...
  my $rs = $schema->resultset('Artist')->search(
    {},
    {
      columns => [ qw/artist_id name rank/ ],
      distinct => 1
    }
  );
...

It *is* a little hard to find, I guess, since the word "distinct" does not
appear in DBIx::Class::Manual::Features, and the explanation of *distinct*
in DBIx::Class::ResultSet only mentions `GROUP BY`.

You can generate the functional form by writing e.g. { ..., columns => [ {
distinct => ... } ] };


On 8 March 2018 at 06:52, Andreas Dafferner <
andreas.dafferner at adw.uni-heidelberg.de> wrote:

> I'm quite new to DBIx and cannot find out what is the DBIx way for
>
> select distinct left (col, (length(col) - 9)) from table order by col
>
> ???
>
> Thank you for any help
>
> Andreas
>
> _______________________________________________
> 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 at lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20180308/5b85f5b9/attachment.htm>


More information about the DBIx-Class mailing list