query builder HAVING clause - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: query builder HAVING clause (/showthread.php?tid=63534) |
query builder HAVING clause - mIden - 11-10-2015 Hello! I'm trying to write SQL with query builder(QB). I want to use HAVING clause with MIN() function in it. In Mysql CLI everything works fine, but QB produce string with "IS NULL" in the end. $this->db->HAVING('MIN(sp.s_price)', null, false); $this->db->HAVING('MIN(sp.s_price)', '', false); It's didn't help. Code: SELECT `s`.`s_code`, `sp`.`s_price` PHP Code: $srvcCode = 'q'; I found workaround $this->db->having("MIN(sp.s_price)", "MIN(sp.s_price)", false); But It's not a good practice. Is it a bug or I didn't understand something? English isn’t my first language, so please excuse any mistakes RE: query builder HAVING clause - pdthinh - 11-10-2015 (11-10-2015, 04:20 PM)mIden Wrote: Hello! Your HAVING clause missed an operator. That's why Query Builder issues an IS NULL for it. You can read about SQL HAVING here and QB having() here |