title: DISTINCT GROUP_CONCAT inside CONCAT
body: <p>I have two tables.</p>
  
  <pre><code>vehicle
  +---------+---------+---------+---------------+-------------+---------+-----------+
  |   ID    |  number | country | estimate_desc | description | est_date| entry_date|
  +---------+---------+---------+---------------+-------------+---------+-----------+
  
  AND vehicle_history
  
  +---------+---------+---------------+-------------+---------+--------------+
  |   ID    |  number | estimate_desc | description | est_date| entry_date   |
  +---------+---------+---------------+-------------+---------+--------------+
  </code></pre>
  
  <p>In the page there is a table with data from vehicle table. Also there is additional column with description history. each time row is edited or added new (you can edit only vehicle data not veh_history) description, estimated_event, est_event_date, entry date is saved into veh_history table. What I need is to get all distinct data from veh_history table not older than 7 days. My attached code is partialy working because, if e.g I fill only description or only est_event I cant get this data. It works when both fields are filled.</p>
  
  <pre><code>$this-&gt;_sql['select'] = ...main table data
  $this-&gt;_sql['from'] = ...main table
  
  if (filter checkbox is checked) {
  
  $this-&gt;_sql['select'].= " , CONCAT(GROUP_CONCAT(DISTINCT est.date_estimate, ' - ' , est.description_estimate SEPARATOR '&lt;BR&gt;'), '&lt;BR&gt;', GROUP_CONCAT(DISTINCT des.date_entry, ' - ' , des.description SEPARATOR '&lt;BR&gt;')) as description_joined";
  
  $this-&gt;_sql['from'].= "LEFT JOIN (SELECT * FROM veh_vehicle_history 
                                 WHERE date_estimate &gt; DATE_ADD(NOW(), INTERVAL -7 DAY) AND description_estimate &lt;&gt; '' GROUP BY description_estimate ORDER BY date_estimate DESC ) 
                                 as est ON est.tractor_unit_id=veh.object_id
                                 LEFT JOIN (SELECT * FROM veh_vehicle_history 
                                 WHERE date_entry &gt; DATE_ADD(NOW(), INTERVAL -7 DAY) AND description &lt;&gt; '' GROUP BY description ORDER BY date_entry DESC ) 
                                 as des ON des.tractor_unit_id=veh.object_id
                                ";
  }
  </code></pre>
  
  <p>I need to filter distinct values (description, estimate_description) and show these values in one string.</p>