title: What is Laravel QB update with Join as 'select' correct syntax?
body: <p>I have correct MySQL query that works fine and I tried to push it into Laravel Query Builder syntax, but not understand some little part.</p>
  
  <p>I tried to write QB expression (see below).</p>
  
  <p>It's my SQL query:</p>
  
  <pre><code>    update LOW_PRIORITY zoho_contacts z
      inner join
      (select contactid,  min(due_date) as mini_date
      from zoho_invoices
      where deleted_at is null and due_date is not null and summa_oplaty &gt; 0
      group by contactid ) co using (contactid)
      set z.data_pervoy_pokupki = co.mini_date
      where z.contactid = co.contactid AND z.data_pervoy_pokupki IS null
  </code></pre>
  
  <p>It's my QB query:</p>
  
  <pre><code>        DB::table('zoho_contacts z')
              -&gt;join(DB::table('zoho_invoices')
              -&gt;select(DB::raw('contactid,  min(due_date) as mini_date'))
              -&gt;whereNull('deleted_at')
              -&gt;whereNotNull('due_date')
              -&gt;where('summa_oplaty', '&gt;', 0)
              -&gt;groupBy('contactid') . ' as co', 'z.contactid', 'co.contactid' )
          -&gt;update(['z.data_pervoy_pokupki' =&gt; 'co.mini_date'])
          -&gt;where('z.contactid', 'co.contactid')
          -&gt;whereNull('z.data_pervoy_pokupki');
  
          dd(DB::getQueryLog());
  </code></pre>
  
  <p>this my expression produces error</p>
  
  <pre><code>Object of class Illuminate\Database\Query\Builder could not be converted to string
  </code></pre>
  
  <p>pointing to string</p>
  
  <pre><code>-&gt;groupBy('contactid') . ' as co', 'z.contactid', 'co.contactid' )
  </code></pre>
  
  <p>I suggest that error is ' as co' because it placed in not proper place.
  I need this alias because I have this</p>
  
  <pre><code>-&gt;where('z.contactid', 'co.contactid')
  </code></pre>
  
  <p><strong>How can I to name result of query nested into Join?</strong></p>
  
  <pre><code>-&gt;select(DB::raw('contactid,  min(due_date) as mini_date'))
      -&gt;whereNull('deleted_at')
      -&gt;whereNotNull('due_date')
      -&gt;where('summa_oplaty', '&gt;', 0)
      -&gt;groupBy('contactid') . ' as co', 'z.contactid', 'co.contactid'
  </code></pre>