I think the majority of CakePHP users are using MySQL, so it could be a 
bug in the cake's MSSQL datasource. You should do some investigating 
into what query is generated, does it run if you try it through sql 
server directly? If not, what needs to be changed for it to work? Then 
look at the mssql datasource and see if it's a bug or whether it could 
be improved upon. If not then you may just need to execute a raw sql 
query instead of using the find methods.

Cheers,
Adam

blake wrote:
> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to