Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2007
    Posts
    7

    Unanswered: Update Query Please help!!

    I am new to databases and I am using Microsoft sample databse to help build my application, but with the northwind database when an order is made it does not update the product table to show how much units are in stock after the order is made.
    I tried to do an update query but i only works when I order one item and does not work when i place an order for more than one. Can someone please help me.

    My order form is built in the same manner as in the sample database.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sorry, crystal ball not working at the moment

    (it runs on Windows 98 and it's currently trying to reboot)

    you're going to have to show us the query
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2007
    Posts
    7
    UPDATE Parts SET Parts.PartsInStock = [Form]![PurchaseOrder_subfrm]![Update] WHERE [Parts].[PartID] = [Form]![PurchaseOrder_subfrm]![PartID];

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SET Parts.PartsInStock
    = Parts.PartsInStock - [Form]![PurchaseOrder_subfrm]![Update]
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2007
    Posts
    7
    When I use thqt Sql it update all the products even it was not in the order.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    AND [Parts].[PartID] = [Form]![PurchaseOrder_subfrm]![PartID];
    George
    Home | Blog

  7. #7
    Join Date
    Oct 2007
    Posts
    7
    Are you saying that the new SQL shoud be:

    Code:
    UPDATE Parts SET Parts.PartsInStock = Parts.PartsInStock - [Form]![PurchaseOrder_subfrm]![Update] AND [Parts].[PartID] = [Form]![PurchaseOrder_subfrm]![PartID];

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nope...

    Try adding my part to the end of r937's post.
    George
    Home | Blog

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    george, you can't AND unless there's already a WHERE
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Pfff, you can if you err...
    There could be an ON or HAVING proceeding it
    George
    Home | Blog

  11. #11
    Join Date
    Oct 2007
    Posts
    7
    ok thanks ppl a lot

  12. #12
    Join Date
    Oct 2007
    Posts
    7
    ok thanks a lot ppl.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •