Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Update Table

Update Table

Scheduled Pinned Locked Moved Database
databasequestionsaleshelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jetset32
    wrote on last edited by
    #1

    Hi, This is really bugging me, I have a product table with a quantity column, When a user buys an item I want the quantity column to change to "SOLD" or 0. The thing is, how do I do this if a customer buys more than one item at a time? I need to be able to pass the number of product ID's to the database and then let a stored procedure UPDATE the selected ProductID's Quantity column to "SOLD" or 0. Somebody help or put me in the right direction! I have tried all i can think of but my SQL knowledge is limited! Thanks in advance JetSet

    Y 1 Reply Last reply
    0
    • J jetset32

      Hi, This is really bugging me, I have a product table with a quantity column, When a user buys an item I want the quantity column to change to "SOLD" or 0. The thing is, how do I do this if a customer buys more than one item at a time? I need to be able to pass the number of product ID's to the database and then let a stored procedure UPDATE the selected ProductID's Quantity column to "SOLD" or 0. Somebody help or put me in the right direction! I have tried all i can think of but my SQL knowledge is limited! Thanks in advance JetSet

      Y Offline
      Y Offline
      Yulianto
      wrote on last edited by
      #2

      Hope this will help, when the user buy 3 item with the product ID 2, execute the stored procedure passing the quantity and the ID update TableName set Qty=Qty-@Qty where ID=@ID


      Work hard and a bit of luck is the key to success.

      You don`t need to be genius, to be rich.

      J 1 Reply Last reply
      0
      • Y Yulianto

        Hope this will help, when the user buy 3 item with the product ID 2, execute the stored procedure passing the quantity and the ID update TableName set Qty=Qty-@Qty where ID=@ID


        Work hard and a bit of luck is the key to success.

        You don`t need to be genius, to be rich.

        J Offline
        J Offline
        jetset32
        wrote on last edited by
        #3

        thanks, I worked it out in the end, and it only took me the whole day!!! UPDATE Products SET ProdQuantity = 0 WHERE ProductID =(SELECT ProductID FROM ShoppingCart WHERE ProductID = Products.ProductID and ShoppingCart.CartID=@CartID) Their you go Thanks again

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups