0

I have 3 tables:

  • Products containing IDProduct, IDCategory, Name
  • Suppliers containing IDSupplier, SupplierName, Phone
  • ProductSupplier containing IDProduct, IDSupplier, Price, Quantity

I want to update (edit) the following: IDCategory, Name(product), IDSupplier, Price, Quantity, but i'm not doing the UPDATE query right:

$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!

1
  • PF.IDProdus shouldn't it be PS.IDProdus? there is no PF table Commented Jan 13, 2011 at 19:42

1 Answer 1

1

http://forums.mysql.com/read.php?20,85813,85813#msg-85813 this thread should give you all the answers you need. In essence you should be using a join.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.