title: Datatables server-side processing INNER JOIN or multiple tables
body: <p>Below is my code without server-side processing but as it produces many rows and will grow considerably I need to use server-side processing.</p>
  
  <hr>
  
  <p>DB Tables (not all fields included but these are the ones i want and the fields to INNER JOIN):</p>
  
  <pre><code>course_modules -       id (pk), course(course.id), module(module.id), added(UNIXTIMESTAMP)
  course -               id (pk), category(course_categories.id), fullname(text)
  course_categories-     id (pk), name(text)
  modules-               id (pk), name(text)
  </code></pre>
  
  <p>I want to be able to display the UNIXTIMESTAMP as date('d/m/Y');</p>
  
  <hr>
  
  <p>Would this work for the INNER JOIN</p>
  
  <pre><code>$sQuery = "
      SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
      FROM   $sTable 
      INNER JOIN modules ON $sTable.module = modules.id 
      INNER JOIN course ON $sTable.course = course.id 
      INNER JOIN course_categories ON course.category = course_categories.id
      $sWhere
      $sOrder
      $sLimit
  ";
  </code></pre>
  
  <hr>
  
  <p>Original php version without server-side processing:</p>
  
  <pre><code>$mods = get_records_sql("SELECT * FROM {$CFG-&gt;prefix}course_modules");
  
  foreach ($mods as $mod)
      {
  
      $thecourse = get_record('course','id',$mod-&gt;course); 
      $themodule = get_record('modules','id',$mod-&gt;module); 
      $thecat = get_record('course_categories','id',$thecourse-&gt;category); 
  
  
      echo '&lt;tr&gt;'; 
      echo '&lt;td&gt;'.$thecat-&gt;name.'&lt;/td&gt;'; 
      echo '&lt;td&gt;'.$thecourse-&gt;fullname.'&lt;/td&gt;'; 
      echo '&lt;td&gt;'.$themodule-&gt;name.'&lt;/td&gt;'; 
      echo '&lt;td&gt;';
      echo date('d/m/Y', $mod-&gt;added);
      echo'&lt;/td&gt;'; 
      echo '&lt;/tr&gt;'; 
      } 
  </code></pre>
  
  <p>I have server-side processing woking fine with my datatables but without linking to the other tables. This table only returns IDs and I want to be able to get the value from another table as demonstrated above.</p>
  
  <p>Do I need to use an innner join? If so how can I incorporate with server_processing.php script:
  I used this one: <a href="http://datatables.net/release-datatables/examples/data_sources/server_side.html" rel="nofollow">http://datatables.net/release-datatables/examples/data_sources/server_side.html</a></p>
  
  <p>Or can I incorporate my above method within server_processing.php.</p>
  
  <p>Any guidance would be greatly appreciated.
  Thanks in advance.</p>