gpt4 book ai didi

php - 内连接 : where clause is too ambiguous

转载 作者:行者123 更新时间:2023-11-29 03:49:38 29 4
gpt4 key购买 nike

我收到错误 “Integrity constraint violation: 1052 Column 'restaurant_id' in where clause is ambiguous' in”

a) 如何在 JOIN 上使用 bindparam?这甚至是导致此错误的问题吗?

function restaurant(PDO $dbh, $username) {
global $dbh;
$stmt = $dbh->prepare("
SELECT *
FROM users u
INNER JOIN menues m
ON u.user_id = m.restaurant_id
INNER JOIN users_slider s
ON m.restaurant_id = s.restaurant_id
WHERE restaurant_id = :restaurant_id
");

$stmt->bindParam(":restaurant_id", $_GET['r']);
$stmt->execute();
return $stmt->fetchAll();
}

最佳答案

改变

...
WHERE restaurant_id = :restaurant_id

...
WHERE m.restaurant_id = :restaurant_id
^^

关于php - 内连接 : where clause is too ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16830094/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com