WHERE clause not working in inner-join query in MySQL

Can anyone please tell me if I put the where clause on the wrong part of my query?

$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;

Answers


The query is the right syntax:

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

However, in your WHERE clause I have a feeling you are looking for a payment date that is literally equal to the string $fulldate. Try concatenating your string for the query differently.


Need Your Help

On-device debugging with Sony Ericsson Cedar (J108i)

debugging java-me sony

Unfortunately, I have to deal with J2ME (which I consider ancient technology these days) on Sony Ericsson J108i (aka Cedar).