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