$c->stash->{routes} = [$c->model('QDB::Route')->search( { 'me.net_id' => $c->stash->{net_id}, -and => [ 'me.route_beg' => 'nodes.node_id', 'me.net_id' => 'nodes.net_id', 'me.route_end' => 'nodes_2.node_id', 'me.net_id' => 'nodes_2.net_id' ], }, { join => ['nodes', 'nodes'], 'select' => [ 'me.route_beg', 'me.route_end', \'nodes.node_name AS node_name_beg', \'nodes_2.node_name AS node_name_end', \'COUNT(me.route_beg) as grp_count', ], 'as' => [ qw/ route_beg route_end node_name_beg node_nam +e_end route_grp_count / ], 'group_by' => [qw/ me.route_beg me.route_end nodes.node_name + nodes_2.node_name /], 'order_by' => [ qw/ node_name_beg/ ], page => $page, # page to return (defaults to 1)use Data::Du +mper; die "SEARCH" . Dumper($new_attrs); rows => $rows, # number of results per page }, )];
I create new with join, but it still MISSING Group By SQL:
SELECT * FROM ( SELECT TOP 10 * FROM ( SELECT TOP 10 me.route_beg, me.route_end, nodes.node_name AS +node_name_beg, nodes_2.node_name AS node_name_end, COUNT(me.route_beg +) as grp_count FROM vi_route me JOIN vi_nodes nodes ON ( nodes.node_ +id = me.route_beg ) JOIN vi_nodes nodes_2 ON ( nodes_2.node_id = me. +route_beg ) WHERE ( ( ( me.route_beg = ? ) AND ( me.net_id = ? ) AND +( me.route_end = ? ) AND ( me.net_id = ? ) ) AND me.net_id = ? ) ORDE +R BY node_name_beg ASC ) AS foo ORDER BY node_name_beg DESC ) AS bar ORDER BY node_name_beg ASC : 'nodes.node_id', 'nodes.net_id', 'nodes_2.node_id', 'nodes_2.net_id' +, 'СЕВ'
NO NEEDED GROUP BY!!! And sql becomes bad//((

In reply to Re^2: dbix-class paging troubles - GROUP_BY by dreel
in thread dbix-class paging troubles - GROUP_BY by dreel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.