你好,我的代码有问题。我正在尝试从我的一个表中提取klantid,这样我就可以使用它从另一个表中提取信息。但我已经尝试了很长时间,并不知道它会是什么。希望有人知道如何修复它。
$autotype = $_POST["autotypevak"];
require_once "gar-connect.php";
$autos = $conn->prepare ("select autokenteken,
automerk,
autotype,
autokmstand,
klantid
from auto
where autotype = :autotype") ;
$autos->execute (["autotype" => $autotype]) ;
$klantid = $autos->fetch(["klantid"]);
$klanten = $conn->prepare ("select klantid,
klantnaam,
klantadres,
klantpostcode,
klantplaats
from klant
where klantid = :klantid") ;
$klanten->execute (["klantid" => $klantid]);
发布于 2021-01-24 22:29:35
你为什么不试试这样的东西:
SELECT klantid, klantnaam,klantadres,klantpostcode,klantplaats
FROM klant k
INNER JOIN `auto` a ON k.klantid = a.klantid
WHERE autotype = :autotype
您的问题可能是从第一个FROM
开始的。auto
是一个关键字,当您从该表中进行选择时,必须使用`
将其括起来。
https://stackoverflow.com/questions/65871680
复制相似问题