Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    47

    Unanswered: strange update query ........

    I have two tables [InvUpdate] and [product] the [InvUpdate] is sent to me everyday with updated inventory numbers and the [product] is my store database that I have to update .

    I need to compare [product.product_inv] to [InvUpdate.Stock] and update [product.product_inv] if [InvUpdate.Stock] is different than [product.product_inv]

    Something like :

    UPDATE product, InvUpdate SET product.product_inv = InvUpdate.Stock
    WHERE (((product.product_id)=InvUpdate.ItemID));


    product.product_id and InvUpdate.ItemID are the part numbers and should be equal to allow the update .

    I thought the statement above would work but , it wants to update like 30,000 rows in a database with only 1500 records ..........

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    update product
    inner 
      join InvUpdate 
        on product.product_id = InvUpdate.ItemID
       set product.product_inv = InvUpdate.Stock
     where product.product_inv <> InvUpdate.Stock
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2003
    Posts
    47

    that got it !

    Thank you that worked !

Posting Permissions

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