为什么这不起作用?我试图仅在不符合我的要求时才插入新数据。
$stm= "INSERT INTO `orders` (userid, username, quantity, time, image, uprice, tprice)
VALUES
(:userid, :username, :quantity, :timee, :image, :uprice, :tprice)
WHERE NOT EXISTS (select username from orders where username=:username and image=:image)";
答案 0 :(得分:1)
使用INSERT .... VALUES
代替WHERE
,不允许使用INSERT .... SELECT
子句:
$stm= "INSERT INTO `orders` (userid, username, quantity, time, image, uprice, tprice)
SELECT :userid, :username, :quantity, :timee, :image, :uprice, :tprice
WHERE NOT EXISTS (select username from orders where username=:username and image=:image)";