我通过 LEFT JOIN 在此查询中加入了许多表,我想在表上应用条件,但 php 给了我以下错误
错误号:1054 'on 子句'中的未知列'2021-08-23'
选择 i.isn_Add_Date, s.scentre_Name, i.isn_Job_No,cp.cpart_Part_Id, cp.cpart_Part,cp.cpart_Qty,cp.cpart_Rate,cp.cpart_Amount, p.product_Name,m.model_Name,c.complaint_Job_No,c.complaint_Add_Date, c .complaint_Under_Warranty,cp.cpart_Qty,cp.cpart_Rate,cp.cpart_Amount FROM 投诉为 c LEFT JOIN 投诉部分为 cp ON c.complaint_Id = cp.cpart_Complaint_Id LEFT JOINscentres as s ON s.scentre_Id = c.complaint_Scentre_Id LEFT JOIN products as p ON p.product_Id = c.complaint_Product_Id 左连接模型为 m ON m.model_Id = c.complaint_Model_Id 左连接为 i ON i.isn_Complain_Number = c.complaint_Job_No AND i.isn_Add_Date BETWEEN '2021-08-23' AND '2021-08 -26' 其中 c.complaint_Scentre_Id = '1' AND c.complaint_Status = 'Delivered' AND c.complaint_Trash = 0
这是我的php代码
$this->db->select('i.isn_Add_Date,s.scentre_Name,i.isn_Job_No,cp.cpart_Part_Id,cp.cpart_Part,cp.cpart_Qty,cp.cpart_Rate,cp.cpart_Amount,p.product_Name,m.model_Name,c.complaint_Job_No,c.complaint_Add_Date,c.complaint_Under_Warranty,cp.cpart_Qty,cp.cpart_Rate,cp.cpart_Amount');
$this->db->join('complaint_parts as cp', 'c.complaint_Id = cp.cpart_Complaint_Id ', 'left');
$this->db->join('scentres as s', 's.scentre_Id = c.complaint_Scentre_Id', 'left');
$this->db->join('products as p', 'p.product_Id = c.complaint_Product_Id', 'left');
$this->db->join('models as m', 'm.model_Id = c.complaint_Model_Id', 'left');
$this->db->JOIN('isn as i', 'i.isn_Complain_Number = c.complaint_Job_No AND i.isn_Add_Date BETWEEN '.str_replace('/', '-', $fromDate).' AND '.str_replace('/', '-', $toDate).'', 'LEFT');
$this->db->where("c.complaint_Scentre_Id", $serviceCenterId[0]);
$this->db->where("c.complaint_Status",'Delivered');
$this->db->where("c.complaint_Trash", 0);
$query = $this->db->get("complaints as c");