Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-07-02 22:58:35

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Need help with complex MySQL query... any takers?

How about
select a.id, a.name, a.value from testquery a, (select max(id) as id, name from testquery group by name) b where a.id = b.id

Results
id name value
3 lion meat
2 monkey apple
5 snake insect


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#14 2008-07-02 23:03:29

Sam
Member
From: New York City
Registered: 2004-06-26
Posts: 127
Website

Re: Need help with complex MySQL query... any takers?

MattD, was just about to go to bed but I think you’ve cracked it! Top work.

Offline

#15 2008-07-02 23:05:16

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Need help with complex MySQL query... any takers?

No problem. I should have had it write on the first try!


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#16 2008-07-02 23:11:12

Sam
Member
From: New York City
Registered: 2004-06-26
Posts: 127
Website

Re: Need help with complex MySQL query... any takers?

Thanks again. The final statement looks like so:

select * from updates a, (select max(id) as id, name from updates group by name) b where a.id = b.id

Last edited by Sam (2008-07-02 23:12:06)

Offline

Board footer

Powered by FluxBB