One think to have in mind would be from the documentation:

"The "as" <https://metacpan.org/pod/DBIx::Class::ResultSet#as> attribute has *nothing to do* with the SQL-side identifier aliasing AS."

instead you should write

|||select => ['me.noabt', { count| |=> ||'abojrnabt.noabt'||, ||-as| |=> ||'count_abo'| |} ] (untested) |


On 2017-01-13 15:35, RAPPAZ Francois wrote:
I'm trying to use count and having
I have
Abo a table of rows describing orders (primary key: noabt)
abojrnabt a relationship between this Abo table a Jrnabt table of 2 columns 
(noabt, nofm)

I would like to know if a specific order has 2 or more corresponding rows in 
Jrnabt

I'm trying

$schema->resultset('Abo')->search_rs(
                        {
                           'me.noabt' => $value,
                        },
                       {   select => ['me.noabt', {count => 'abojrnabt.noabt'}],
                           as     => [qw/noabt count_abo/],
                           join       => ['abojrnabt'],
                           group_by   => ['noabt'],
                           having => [ { 'count_abo' => { '>' => 1 } } ],
                       },
);
But this fails with
***   DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st 
execute failed:
        Unknown column 'count_abo' in 'having clause' [for Statement
        "SELECT me.noabt FROM abo me WHERE ( me.noabt = ? ) GROUP BY noabt HAVING count_abo > 
?" with ParamValues: 0="919", 1=1] at ...

Thanks for any suggestion

Fran├žois

_______________________________________________
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

_______________________________________________
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

Reply via email to