Hi, How to use arithmetic conditions in cakephp find. For Ex: select * from table where a_column+b_column>500 If any one know the way,Please reply..
If a_column and b_column are numeric columns, that should work. If they're not, you'll have to use CAST to convert each of them to a numeric value first. ('one' + 'two' isn't 'three', it's 'onetwo'.) So "SELECT * FROM table WHERE (CAST(a_column AS DECIMAL) + CAST(b_column AS DECIMAL)) > 500;" That's all assuming that your database is MySQL. For other databases the syntax may be different.
Hi, You can use conditions like this: $test = $this->Invoice->find('all', array('conditions' => array('(Invoice.total_price + Invoice.shipping_rate) >' => 100) )); Hope its help.