MySQL
同一个数据库中有两个表:matware和matinout
matware:fstockcode,fqty06,fwareqty
matinout:fstockcode,finqty,foutqty
请问以下语法如何写:
以matware.fstockcode=matinout.fstockcode为条件,
更新matware.fwareqty=(matware.fqty06+matinout.finqty)-matinout.foutqty

解决方案 »

  1.   

    update matware,matinout
     set matware.fwareqty=(matware.fqty06+matinout.finqty)-matinout.foutqty
     where matware.fstockcode=matinout.fstockcode
      

  2.   

    mysql> update matware,matinout set matware.fwareqty=(matware.fqty06+,matinout.finqty)-matinout.foutqty where matware.fstockcode=matinout.fstockcode;
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'matinout.finqty)-matinout.foutqty where matware.fstockcode=mati
    mysql>