我试图修复此查询,但出于某种原因,它会抛出错误。 我应该做些什么改变?
代码
$statement=$conn->prepare("SELECT p.productid AS productid,
p.productname AS productname,
t.itemid AS itemid,t.amount AS amount,
t.is_completed AS is_completed,
t.id AS recordid
FROM products p,temporder t
where p.productid=t.itemid AND is_completed = 0
LIMIT 0, 30 AND t.email = ?");
$statement->execute(array($_SESSION['email']));
$rows=$statement->rowCount();//get no. of rows
$statement->setFetchMode(PDO::FETCH_ASSOC);
错误:
SQLSTATE [42000]:语法错误或访问冲突:1064您有 SQL语法错误;查看与您的手册相对应的手册 MySQL服务器版本,用于在' AND t.email =附近使用正确的语法 ' test@gmail.com''在第1行
答案 0 :(得分:3)
更改此
where p.productid=t.itemid AND is_completed = 0 LIMIT 0, 30 AND t.email = ?
到
where p.productid=t.itemid AND is_completed = 0 AND t.email = ? LIMIT 0, 30