将此sql代码转换为codeigniter?

ryoqjall  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(313)

如何将此sql代码转换为codeigniter?

SELECT *,sum(sales_total) as daily_report FROM `tbl_sales`,(select 
    sum(sales_total) as month from tbl_sales where date_format(sales_date,'%m') = '01') as totals where sales_date = '2018-01-18'
ix0qys7i

ix0qys7i1#

$sub_query_from = "tbl_sales,(SELECT SUM(sales_total) AS month FROM tbl_sales WHERE date_format(sales_date,'%m') = '01') AS totals";
$this->db->select('*, SUM(sales_total) AS daily_report');
$this->db->from($sub_query_from);
$this->db->where('sales_date','2018-01-18');
$query = $this->db->get();

相关问题