WHERE子句在MySQL中的内连接查询中不起作用

时间:2015-12-03 15:43:46

标签: mysql codeigniter inner-join

如果我把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;

1 个答案:

答案 0 :(得分:2)

查询是正确的语法:

select * 
from payments 
inner join $building 
on payments.stallnum=$building.stallNum 
where payments.paymentdate='$fulldate'

但是,在您的WHERE条款中,我感觉您正在寻找一个字面上等于字符串$fulldate的付款日期。尝试以不同方式连接查询字符串。