did you try it this way: (field1-field2) as foo
maybe you need the parenthesis... not sure though but i know that MAX(...) etc works - so that would be my guess On 11 Sep., 16:01, Andrew Koebbe <andrew.koe...@gmail.com> wrote: > Thanks for the suggestion. If I do that it back-ticks the whole thing > > select `x-y` AS `difference` from ... > > putting spaces around the minus sign produces similar errors. Is there > a way to remove the back ticks for that field? > > --Andrew > > On Sep 11, 7:44 am, Rick <will...@gmail.com> wrote: > > > Assuming you don't need recursion, try it without the model names, > > i.e. > > > 'x-y as difference' > > > Rick > > > On Sep 10, 5:33 pm, Andrew Koebbe <andrew.koe...@gmail.com> wrote: > > > > I'm trying to do a simple subtraction as a field in a find statment... > > > > ex. > > > > $this->Model->find('all',array( > > > 'fields' => array( > > > 'Model.x - Model.y as difference' > > > ) > > > )); > > > > but it's not parsing that correctly. > > > > It's doing "select `Model`.`x - Model.y as difference` from ..." > > > > Am I missing something simple here? > > > > I know I could do the subtraction outside the query, but I want to be > > > able to order the query by the result of this subtraction. > > > > Thanks. > > > --Andrew --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---