<div dir="ltr"><div><div><div><div><div>I have two tables with a many-to-many relationship, say:<br><br></div>Table A    A_B (Join Table)   Table B<br><br></div>Any
 A can have many B, and any B can be assigned to any A.  All via the 
join table. Each of A and B has an &#39;id&#39; and &#39;name&#39; column (and likely 
many other columns that are unimportant for this example).  <br><br></div>If
 I want to find all A that have any one B assigned to it *and* retrieve 
all B for the selected A *and* do this in one query I&#39;ve been doing 
this:<br><br>my $rs = $s-&gt;resultset( &#39;A&#39; )               <br>           -&gt;search( { &#39;B.name&#39; =&gt; &#39;some_name&#39; },<br>                     { prefetch =&gt; [ { A_B =&gt; &#39;B&#39; },<br>                                     { A_B =&gt; &#39;B&#39; } ] } );<br><br></div>I
 list the prefetch twice. If I only list it once I only get those B that
 match the search criteria, instead of all B for the selected A.<br><br></div>I now want to do the same thing, but only return those columns from A and B that I want.  So I tried this:<br><br>my $rs = $s-&gt;resultset( &#39;A&#39; )               <br><div>           -&gt;search( { &#39;B.name&#39; =&gt; &#39;some_name&#39; },<br>                     { columns =&gt; [ &#39;id&#39;, { &#39;<a href="http://A_B.B.name" target="_blank">A_B.B.name</a>&#39; =&gt; &#39;B.name&#39; } ],<br>                       collapse =&gt; 1,<br>                       join =&gt; [ { A_B =&gt; &#39;B&#39; },<br>                                 { A_B =&gt; &#39;B&#39; } ] } );<br><br></div><div>This
 does return only the columns I ask for, but it also only returns the B 
that match the search criteria instead of all B for the selected A.  <br></div><div><br></div><div>Is there a way I can get the same results as my first example, but by only returning the columns like from  my second example?<br></div><div><br></div><div>I&#39;ve been using DBIx::Class 0.082810.  <br><br></div>Thank you.</div>