<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>One think to have in mind would be from the documentation:</p>
<p>"The <a
href="https://metacpan.org/pod/DBIx::Class::ResultSet#as">"as"</a>
attribute has <b>nothing to do</b> with the SQL-side identifier
aliasing AS."</p>
<p>instead you should write</p>
<pre><div class="line number5 index4 alt2"><code class="perl spaces"> </code><code class="perl plain">select => ['me.noabt', { count</code> <code class="perl plain">=> </code><code class="perl string">'abojrnabt.noabt'</code><code class="perl plain">, </code><code class="perl string">-as</code> <code class="perl plain">=> </code><code class="perl string">'count_abo'</code> <code class="perl plain">} ]
(untested)
</code></div></pre>
<p> <br>
</p>
<div class="moz-cite-prefix">On 2017-01-13 15:35, RAPPAZ Francois
wrote:<br>
</div>
<blockquote
cite="mid:b244b42115bf41668d958b95c654e824@svw-exmb1.unifr.ch"
type="cite">
<pre wrap="">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: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a>
IRC: irc.perl.org#dbix-class
SVN: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a>
Searchable Archive: <a class="moz-txt-link-freetext" href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a>
</pre>
</blockquote>
<br>
</body>
</html>