简体   繁体   English

php mysql更新多个表

[英]php mysql updating in multiple tables

I have 3 tables: 我有3张桌子:

  • Products containing IDProduct, IDCategory, Name 包含IDProduct,IDCategory,名称的产品
  • Suppliers containing IDSupplier, SupplierName, Phone 包含IDSupplier,SupplierName,电话的供应商
  • ProductSupplier containing IDProduct, IDSupplier, Price, Quantity 包含IDProduct,IDSupplier,价格,数量的ProductSupplier

I want to update (edit) the following: IDCategory, Name(product), IDSupplier, Price, Quantity, but i'm not doing the UPDATE query right: 我想更新(编辑)以下内容:IDCategory,名称(产品),IDSupplier,价格,数量,但我没有正确执行UPDATE查询:

$query="UPDATE products P, 
               category C, 
               suppliers S, 
               productsupplier PS 
           SET P.IDCategory = '$idcategory', 
               P.Name = '$Name', 
               S.IDSupplier = '$idsupplier',  
               PS.Price = '$Price', 
               PS.Quantity = '$Quantity'
         WHERE ((IDProduct = '$idproduct') 
           AND (P.IDProdus = PF.IDProdus) 
           AND (PS.IDSupplier = S.IDSupplier ) 
           AND (P.IDCategory = C.IDCategory))");  

How do i do this right? 我该怎么做对? Thank you! 谢谢!

http://forums.mysql.com/read.php?20,85813,85813#msg-85813 this thread should give you all the answers you need. http://forums.mysql.com/read.php?20,85813,85813#msg-85813该线程应该为您提供所需的所有答案。 In essence you should be using a join. 本质上,您应该使用联接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM