我的orderdetails表有orderdetailsID(PK),products_id(FK),customers_id(FK)和Quantity我想插入新订单如果products_id不存在则如果它确实存在那么更新数量这是否可能在mysql中?
$sql = "INSERT INTO orderdetails (products_id, Quantity, customers_id) VALUES($id,$stock,$customers_id) ON DUPLICATE KEY UPDATE
Quantity = VALUES(Quantity);
";