$getCart=$user_home->runQuery("SELECT ID, productTitle, manufacturer, cost FROM Products LEFT JOIN shopCart
ON 'Products.ID'='ShopCart.productID'");
$getCart->execute();
$getCart->execute();
行的gettting错误:
' SQLSTATE [23000]:违反完整性约束:1052列' ID'字段列表中含糊不清
我已经阅读了相关问题,但我还没有找到解决方案。
答案 0 :(得分:1)
由于你使用2个表来加入JOIN,你必须精确地使用表格:
$getCart=$user_home->runQuery("SELECT Products.ID, productTitle, manufacturer, cost FROM Products LEFT JOIN shopCart
ON 'Products.ID'='ShopCart.productID'");
答案 1 :(得分:1)
您的查询在多种方面不正确。你可能想要这样的东西:
factory.validateUser = function()
{
var vm = this;
if($location.path() != '/')
{
var api_token = factory.getToken();
factory.isValidToken(api_token).then(function(response) {
if (response.status != 200) {
$location.path('/');
}
data = {"api_token": api_token};
return requestFactory.post(GLOBALS.url + 'show/employee/' + $cookies.get('employeeid'), data)
});
}
}
注意:
SELECT p.ID, p.productTitle, p.manufacturer, sc.cost
FROM Products p LEFT JOIN
shopCart sc
ON p.ID = sc.productID;
子句没有单引号,因为比较两个字符串常量通常没用。