title: select all columns in mysql table but do not show duplicate results, SELECT DISTINCT id
body: <p>i am trying to select * the columns in my table and pull these through using mysql query, i am getting a duplicate result with one row, so i am wanting to NOT show duplicate results from mysql. i am trying to do this using SELECT DISTINCT 'id'</p>
  
  <p>in theory this should not pull trough the row a second time / as a duplicate result then because i am telling it to select each id only once.</p>
  
  <p>this is not working though and i am still getting a duplicate result, please can someone show me where i am going wrong?</p>
  
  <pre><code>$data3 = mysql_query("SELECT DISTINCT id, company_name, company_reg_number, date   
   FROM supplier_session WHERE status != 'Failed'
   ORDER BY date ASC") 
   or die(mysql_error()); 
   while($row = mysql_fetch_array( $data3 )) { 
   $days = $row['date'];
   $when = $days*0; 
   $str = $row['date'];
   $str2 = substr($str, 0); // "quick brown fox jumps over the lazy dog."
   if ($when &lt;= 31){
   echo "&lt;tr&gt;&lt;td style=\"width:100px;\"&gt;&lt;p&gt;".$row['id'] . "&lt;/p&gt;&lt;/td&gt;"; 
   echo "&lt;td style=\"width:150px;\"&gt;&lt;p&gt;".$row['company_name'] . "&lt;/p&gt;&lt;/td&gt;"; 
   echo "&lt;td style=\"width:150px;\"&gt;&lt;p&gt;".$row['company_reg_number'] . "&lt;/p&gt;&lt;/td&gt;";
   echo "&lt;td&gt;"; echo date('d/m/Y',strtotime($row['date'])); echo "&lt;/td&gt;";
   if ($days &gt;= 8) {
   echo "&lt;td style=\"width:200px;\"&gt;&lt;p&gt;";
   print ($str2 -7);
   echo " days overdue&lt;/td&gt;";      
   }
   elseif ($when &lt;= 7){
   echo "&lt;td style=\"width:200px;\"&gt;&lt;p&gt;Completed {$str2} days ago&lt;/td&gt;";
   }}
   $q2 = "SELECT DISTINCT id, company_name, company_reg_number, date FROM supplier_session WHERE status != 'Failed' " or die (mysql_error());
   $result2 = mysql_query($q2);
   $count2 = mysql_num_rows($result2);
   echo "&lt;td&gt;";
   echo "Pending&lt;/td&gt;";
   echo "&lt;tr&gt;";
   }
  </code></pre>
  
  <p>My table looks like:</p>
  
  <pre><code>id  |  session_number  |  user_IP  |  date  |  company_reg_number  |  company_name |  form1_completed  |  form2_completed  |  form3_completed  |  form4_completed  |  completed_date  |  status
  </code></pre>