I have a table that I created in the group of clients and ready the products separated by commas using GROUP_CONCAT (product) AS products2. Except that I need the Group's product listing to be each in a column instead of comma separated.
In short I need to list the products the group has put together into a single line.
SELECT customer, GROUP_CONCAT (product) AS products2 FROM sales GROUP BY customer
Table.
CREATE TABLE IF NOT EXISTS `vendas` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer` int(11) NOT NULL,
`product` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Extraindo dados da tabela `vendas`
--
INSERT INTO `vendas` (`id`, `customer`, `product`) VALUES
(1, 10, 2),
(2, 10, 1),
(3, 11, 1),
(4, 11, 2);