Re: Query-within-a-query with mySQL/PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>Basically I somehow need to do a GROUP BY producer, and yet somehow at the
same time, find out all the matching vintages (years), that go along with
that group and return them the same time the producer group is returned.

If I'm following you correctly, you have a column "year" in your group, and
rather than returning just one year in your result set, you would like every
year in the group.

This can be accomplished with the group_concat() [1] function:

SELECT field1,field2,field3, GROUP_CONCAT(distint year) as years FROM table
WHERE conditions GROUP BY foo;

[1]
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

-- GREG.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux