Ok. The parentheses worked. So the moral of the story is. Don't use model names and put the math in parentheses.
Thanks for the help. --Andrew On Sep 11, 11:01 am, "euromark (munich)" <[email protected]> wrote: > 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [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 -~----------~----~----~----~------~----~------~--~---
