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

From: Date: Sat, 25 Oct 2008 16:21:52 +0000
Subject: Re: Query-within-a-query with mySQL/PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-282427@lists.php.net to get a copy of this message
>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.

« previous php.general (#282427) next »