title: How to join tables with more than one attribute match?
body: <p>I am trying to turn my raw sql into laravel query builder and I encounter difficulty on how to join multiple tables using with many attributes match.</p>
  
  <p>In this case, I want to join the table jr_h and jr_d with three attributes match (book,p_seq and staff_code) rather than one (book).
  Raw sql:</p>
  
  <pre><code> $sql =  "select from_time,to_time,t.staff_code,s.name_t as staff_name,t.book,t.p_code,t.p_seq,p.hrs1,s.img_file, 
          t.hrs_work,p.sharing_cnt  as hrs_work, t.hrs_ot  as hrs_ot from jr_d as t 
          inner join jr_h as p on(t.book=p.book and t.p_seq=p.p_seq and t.staff_code=p.staff_code)  
          inner join astaff as s on(t.staff_code=s.staff_code) ";
  </code></pre>
  
  <p>Laravel query builder:</p>
  
  <pre><code>   $jr_d = DB::table('jr_d')
          -&gt;join('jr_h', 'jr_d.book', '=', 'jr_h.book')
          -&gt;join('astaff', 'jr_d.staff_code', '=', 'astaff.staff_code')
          -&gt;select('jr_h.*','jr_d.*','astaff.*','astaff.name_t as staff_name')
          -&gt;where('jr_d.ref_group','=','E')
          -&gt;get();
  </code></pre>
  
  <p>and also want to know if there is a way to make the query faster since it has a lot of data in the tables.</p>