Show two or more rows in a single row
<p>I have these four tables:</p>

<p>table offers</p>

<ul>
<li>id </li>
<li>id_company </li>
<li>description</li>
</ul>

<p>table companies</p>

<ul>
<li>id</li>
<li>name</li>
</ul>

<p>table company_customer</p>

<ul>
<li>id_company</li>
<li>id_customer</li>
</ul>

<p>table customers</p>

<ul>
<li>id</li>
<li>name</li>
</ul>

<p>I need to get the offers, the company that has the offer and also the customers which have a relation with those companies. It's quite simple.</p>

<p>The query I'm typing is the following:</p>

<pre><code>SELECT c.name, c.description, cu.name cu_name 
        FROM companies c 
        INNER JOIN offers o ON o.id_company = c.id 
        INNER JOIN company_customer cc ON cc.id_company = c.id 
        INNER JOIN customers cu ON cu.id = cc.id_customer 
        WHERE o.id_company = 1 
        ORDER BY o.id_company;
</code></pre>

<p>The "problem" is that sometimes an offer of a company is available for diferent customers.</p>

<p>Let me to show you the problem with a real example:</p>

<p>'Ebay' | 'offer number 1' | 'customer 1'
'Ebay' | 'offer number 1' | 'customer 2'</p>

<p>But I need concatenate or show both rows on a single row (just in the cases that company and the offer is the same but the customers are different). In other words, I need the following result:</p>

<p>'Ebay' | 'offer number 1' | 'customer 1, customer 2'</p>

<p>I work with PHP and MySQL. I know this may be done with PHP but I'm wondering if it could be possible to do it just with MySQL.</p>

<p>Any ideas??</p>

<p>Any help would be really appreciated. My apologize for my english level. I know it's not my best.</p>

<p>Thanks in advance for your time and attention.</p>