Try using mysql group_concat and group by on the client_product table.

E.

From: Nd'wex Common
Sent: 08/10/2012 20:59
To: Skunkworks Mailing List
Subject: Re: [Skunkworks] SQL question

Hi,

I have some tables as follows

products
id
name
categoryid
manufacturer

clients
id
name
address

category
id
title
active

client_product
id
clientid
productid
quantity
date

from the above structures a report is to be generated as follows

date | product1 | product2 | product3 | ---- | product x

under each product are the quantities acquired. each client may have different products.

question is how do i extract the data in the above format using possibly a single query?

thank you in advance