I'm trying to do the following find() to find the highest id for each
name value in the table.
$result = $this->Model->find('all', array('conditions' => array
('Model.parent_id' => $parent_id),
'fields' =>
array('MAX(Model.id) as max_id', 'Model.name'),
'recursive' =>
1,
'group' =>
array('Model.name')
));
For the example table:
1 ItemA
2 ItemB
3 ItemC
4 ItemB
5 ItemA
I want the result (any order):
5 ItemA
4 ItemB
3 ItemC
The find() works in MySQL, but not in MS SQL. MS SQL wants me to group
on Model.id also, which then returns more results than I want. What is
the best way for me to do this query?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---