Welcome Guest, Not a member yet? Register   Sign In
Active record order_by the result of multiplying two fields
#8

(This post was last modified: 11-18-2014, 06:37 PM by bclinton.)

(11-18-2014, 05:22 PM)andycansdale Wrote: I like your idea of running the calculation in the select and then ordering on the new named field. It would be a nice clean way to do it. Perhaps you know how I could get this to work with select_min, which when translated into SQL already has the 'as [field_name]' included. This is the value that needs to be multiplied by the rate.



Code:
$this->db->select_min("project_units.price_min")
becomes


Code:
MIN(`project_units`.`price_min`) AS price_min

can't you just use price_min? 

Also, you don't necessarily have to use select_min, you could use

PHP Code:
$this->db->select("MIN(`project_units`.`price_min`) AS whatever_you_want_to_call_it"
Reply


Messages In This Thread
RE: Active record order_by the result of multiplying two fields - by bclinton - 11-18-2014, 06:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB