如果我把where子句放在查询的错误部分,有人可以告诉我吗?
$year = $this->input->post('yearFilter');
$month = $this->input->post('monthFilter');
$day = $this->input->post('dayFilter');
$building = $this->input->post('buildingFilter');
$fulldate = $year . '-' . $month . '-' . $day;
$query = "select * from payments inner join $building on payments.stallnum=$building.stallNum where payments.paymentdate='$fulldate'";
$run = $this->db->query($query)->result();
return $run;
答案 0 :(得分:2)
查询是正确的语法:
select *
from payments
inner join $building
on payments.stallnum=$building.stallNum
where payments.paymentdate='$fulldate'
但是,在您的WHERE
条款中,我感觉您正在寻找一个字面上等于字符串$fulldate
的付款日期。尝试以不同方式连接查询字符串。