[英]alternative sql syntax for joined table update
I need alternative syntax for my sql, to deduct the qty from another table to my raw material table 我需要我的sql的替代语法,以将另一个表的数量扣除到我的原材料表中
$sql3 = "UPDATE material_inventory
join product_check
ON material_inventory.qty = material_inventory.qty
SET material_inventory.qty = material_inventory.qty - product_check.qty
WHERE product_check.pc_id = '$id'
AND product_check.date2 = '$date'
LIMIT 1";
$result3 = mysqli_query($conn,$sql3);
It looks like limit doesn't work in join update with join clause. 看起来限制在使用join子句的join更新中不起作用。 anyway thanks
还是谢谢你
Looks like your ON
condition is wrong. 看起来您的
ON
条件是错误的。 Until you add schema of relevant tables, all I can suggest from given scenario is following query: 在添加相关表的架构之前,我只能从以下查询中得出给定方案的建议:
$sql3 = "UPDATE material_inventory
join product_check
ON material_inventory.qty = product_check.qty //modified line
SET material_inventory.qty = material_inventory.qty - product_check.qty
WHERE product_check.pc_id = '$id'
AND product_check.date2 = '$date'
LIMIT 1";
$result3 = mysqli_query($conn,$sql3);
If the above query doesn't get the desired output, please add schema so that I can provide more accurate solution. 如果以上查询未获得所需的输出,请添加架构,以便我提供更准确的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.