我在 mysql 中有两个表,即产品和销售。产品包含库存,销售包含采购记录。现在,当我将销售项目的数量插入到销售表中时,我想从库存中出售产品,那么作为产品表的库存中应该减少相同的数量。请帮我查询。
卖表插入。
$cus_id = $_POST['customer'];
$reg_id = $_POST['cus_region'];
$cat_id = $_POST['product'];
$name = $_POST['name'];
$price = $_POST['unit_price'];
$quantity = $_POST['quantity'];
$date = $_POST['datepicker'];
$total = $price * $quantity;
$payment = $_POST['payment'];
$remainig = $total - $payment;
$query = "INSERT INTO sell SET cus_id = '".$cus_id."',reg_id = '".$reg_id."', cat_id = '".$cat_id."',product = '".$name." ', sell_price = '".$price."', sell_date = '".$date."',item_quantity = '".$quantity."',amount_paid= '".$payment."',total_price = '" .$total."', 剩余 = '".$remainig."'";
$res = mysql_query($query);