title: Select only 1 distinct column - SQL
body: <p>I have a table like this in my database</p>
  
  <pre><code>orderID| productID | qty
  1        5           1
  1        2           1
  1        6           1
  1        4           1
  2        9           1
  2        5           2
  2        6           1
  </code></pre>
  
  <p>I want to output it into my HTML/php page in a similar way to this</p>
  
  <pre><code>Order ID:1
  Product ID | Qty
  5          | 1
  2          | 1
  6          | 1
  4          | 1
  Order ID:2
  Product ID | Qty
  9          | 1
  5          | 2
  6          | 1
  </code></pre>
  
  <p>Is this even possible to do? I have tried to use DISTINCT but that only outputs 1 row for each orderID. Here is the closest way I have outputted using the ORDER BY statement at the moment but this makes the headers for every row from the database.</p>
  
  <pre><code>&lt;?php
      if ($query = "SELECT * FROM productOrders ORDER BY orderID"){
          $result = mysqli_query($connection, $query);
  
          if (mysqli_num_rows($result) &gt; 0)
      {
           while($row = mysqli_fetch_assoc($result)) 
           {
          ?&gt;                                          
  
      &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Order ID: &lt;?php echo $row['orderID'] ?&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;Product ID&lt;/th&gt;
          &lt;th&gt;Qty&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $row['productID'] ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['qty'] ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/table&gt;
  &lt;?php
          }
      } 
   ?&gt;
  </code></pre>