Re: php/mysql group by headache
| From: | CPT John W. Holmes | Date: | Fri, 04 Apr 2003 16:30:11 +0000 |
| Subject: | Re: php/mysql group by headache | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142366@lists.php.net to get a copy of this message | ||
> preface: have RTM on mysql GROUP BY
>
> I have a mysql db with a number of entries...
> table| id | name | info | version
> 1 x foo 1
> 2 x foob 2
> 3 x foobar 3
>
> my sql is similar to
> "select id,name,info from table GROUP BY name order by name,version
> desc"
>
> in an effort to only return one result of type (x), but get the most
> recent info (foobar) and version (3), however this isn't the case.
> GROUP BY returns the first info and version it comes across.
>
> Has anyone run across this issue, or know of a solution? Thanks.
Not sure what this has to do with PHP, but...
I know you RTM, but here's a link from it you probably haven't read that
should solve your problem:
http://www.mysql.com/doc/en/example-Maximum-column-group-row.html
---John Holmes...