未知' sensorNamePerso' where子句中的字段

时间:2018-05-09 09:38:06

标签: php pdo

我不知道为什么但是当我编译我的代码时,我收到了这个错误,我试着把引号放在引号上,因为sensorNamePerso是一个字符串,但它没有改变任何东西,你能帮帮我吗?

<?php

     $condi = "WHERE sensorId=".$sensors_id[1]." AND typeId= ".$type_id[1]." AND sensorNamePerso= ".$sensors_name_perso[1]."  AND date >= DATE_ADD(now(),INTERVAL -1 MONTH) ORDER BY date DESC";
     $value2 = $database->sqlRequest("SELECT value FROM historysensor ".$condi, "value");
     $date2 = $database->sqlRequest("SELECT date FROM historysensor ".$condi, "date");


?>

它只是我代码的一小部分

historySensor table

usersensor table

1 个答案:

答案 0 :(得分:0)

我希望这对你有用

<?php

     $condi = "WHERE historysensor.sensorId=".$sensors_id[1]." AND historysensor.typeId= ".$type_id[1]." AND usersensor.sensorNamePerso= ".$sensors_name_perso[1]."  AND historysensor.date >= DATE_ADD(now(),INTERVAL -1 MONTH) ORDER BY date DESC";
     $value2 = $database->sqlRequest("SELECT value FROM historysensor INNER JOIN usersensor ON usersensor.typeId=historysensor.typeId ".$condi, "value");
     $date2 = $database->sqlRequest("SELECT date FROM historysensor INNER JOIN usersensor ON usersensor.typeId=historysensor.typeId ".$condi, "date");


?>