Php 如何在codeigniter中转换
您可以尝试此Codeigniter活动查询: 查询:Php 如何在codeigniter中转换,php,mysql,sql,codeigniter,Php,Mysql,Sql,Codeigniter,您可以尝试此Codeigniter活动查询: 查询: 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
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
我希望它能有所帮助。按照查询生成器的说明进行操作
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;
}