PHP / MYSQL - 使用union更新子查询选择

时间:2016-10-10 01:56:29

标签: php mysql

我在这里得到了我的查询,用于显示使用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中更新我的数量,这是我的主文件

This is my sample output for my Union all and i want to get the data and able to update my quantity in allinvty3 which is my masterfile 这是我所有联盟的示例输出,我想获取数据并能够在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);

我更新时的错误就像下面的建议一样,尽管我的所有字段都是正确的

注意:尝试获取非对象的属性

1 个答案:

答案 0 :(得分:1)

我想你可以这样做:

nmap -p3333 -Pn IpCidrRange/17 --open -oG save.txt

更多来自MySQL herehere中SELECT的更新。