我在这里得到了我的查询,用于显示使用union的On-hand数量因此我可以得到结果。 allinvty3 是我的主文件,我想根据工会的结果更新我的项目的数量。是否可以根据变量输出 $ total 更新到我的 allinvty3 。
**My table :**
|allinvty3|(masterfile)
----------------
|in_code |
|ecr_desc |
|pric_cash
|qty |
|ite_desc |
---------------
|barcode, branchtobranch,adjustment table(all tables have same fieldnames) |
----------------
|itemcode |
|qty |
|status |
---------------
这是我所有联盟的示例输出,我想获取数据并能够在allinvty3中更新我的数量,这是我的主文件
这是我所有联盟的示例输出,我想获取数据并能够在allinvty3中更新我的数量,这是我的主文件
$sql = "UPDATE allinvty3 as A, (
select
ite_desc,ecr_desc, pric_cash, t.itemcode as itemcode ,sum(t.qty) as qty
from (
select ite_desc,ecr_desc, pric_cash, itemcode,qty from barcode as bc inner JOIN allinvty3 as ait on bc.itemcode = ait.in_code
union all
select ite_desc,ecr_desc, pric_cash, itemcode,qty from branchtobranch_tb as bb inner JOIN allinvty3 as ait on bb.itemcode = ait.in_code
union all
select ite_desc,ecr_desc, pric_cash, itemcode,qty from adjustment_tb as adt inner JOIN allinvty3 as ait1 on adt.itemcode = ait1.in_code where adt.status='APPROVED'
union all
select ite_desc,ecr_desc, pric_cash, itemcode,qty from stockreturn_tb as sb inner JOIN allinvty3 as ait on sb.itemcode = ait.in_code
union all
select ite_desc,ecr_desc, pric_cash, itemcode,qty from notinclude_tb as nt inner JOIN allinvty3 as ait on nt.itemcode = ait.in_code where nt.status='COMPLETE'
union all
select ite_desc,ecr_desc, pric_cash, itemcode,qty from purchase_tb as pt inner JOIN allinvty3 as ait on pt.itemcode = ait.in_code
union all
select ite_desc,ecr_desc, pric_cash, itemcode,(qty * -1) from soldout_dm as slp inner JOIN allinvty3 as ait2 on slp.itemcode = ait2.in_code
) as t
) as UD
SET
A.sa_onhand = UD.qty
WHERE
A.in_code = UD.itemcode";
$result = $conn->query($sql);
我更新时的错误就像下面的建议一样,尽管我的所有字段都是正确的
注意:尝试获取非对象的属性