如何在codeigniter中转换

t1qtbnec  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(408)
SELECT sum(`quantity`) as 'Total Product Sales',product.i_name as 'Product Name' 
FROM `order_details` 
inner join orders on orders.order_id = order_details.order_id and orders.status like 'C' 
inner join product on product.p_id = order_details.product_id 
group by order_details.product_id
fkvaft9z

fkvaft9z1#

您可以尝试此codeigniter活动查询:
查询:

public function get_data(){
        $this->db->select("sum(order_details.quantity) as total_product_sales", FALSE);
        $this->db->select("product.i_name as product_name'", FALSE);
        $this->db->from('order_details');
        $this->db->join('orders', 'orders.order_id = order_details.order_id','INNER');
        $this->db->join('product', 'product.p_id = order_details.product_id', 'INNER');
        $this->db->like('orders.status', 'C');
        $query_result = $this->db->get();
        $result = $query_result->result();
        return $result;
    }

我希望这会有帮助。

相关问题