Using proper syntax
$result_set->search(
{},
{ select => [
'winner',
\'COUNT(*) AS votes',
],
as => [
'winner',
'votes',
],
group_by => [
'winner',
],
having =>
{ 'votes' => 6 },
}
);
Produces DBIC_TRACE of:
SELECT winner, COUNT(*) AS votes FROM winners GROUP BY winner HAVING ( votes = ? ): '6'
Short-circuiting placeholders
$result_set->search(
{},
{ select => [
'winner',
\'COUNT(*) AS votes',
],
as => [
'winner',
'votes',
],
group_by => [
'winner',
],
having =>
'votes = 6',
}
);
DBIC_TRACE shows:
SELECT winner, COUNT(*) AS votes FROM winners me GROUP BY winner HAVING ( votes = 6 ):
First fails to return a valid result, second works fine.
|