|
用CI框架写的sql语句如下,
SELECT `product`.`p_id`, `product`.`p_title`, `ua_id`, `p_type`, `p_list_pic`, min(s_price) AS min_price FROM `product` JOIN `size` ON `product`.`p_id` = `size`.`p_id` WHERE `p_putaway` = '2' AND `p_sold_status` = '6'
查找的结果是不存在的,但是由于min(s_price)的存在,使得数据结果得到如下
[{"p_id":null,"p_title":null,"ua_id":null,"p_type":null,"p_list_pic":null,"min_price":null}]
这种情况怎么将NULL去掉?使得未查到的情况输出为空即[](json字符)
我现在的做法是再次在控制器中判断p_id是不是NULL如果是,则从结果数组中去掉,各位有没有在sql语句上的优化,使得控制器中不用去判断![](static/image/smiley/default/handshake.gif) ![](static/image/smiley/default/handshake.gif) |
|