Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008

    Unanswered: how to add a column value

    in my table i have a column Qty ,I want to do Qty +1 each time query is executed then i want to update it to the same column.

    select max(Qty)+1 from hd_spare_detail where reg_no='998'
    update hd_spare_details set Qty=....

    I dnt know how to update it
    Please help me out its urgent

  2. #2
    Join Date
    Nov 2004
    Provided Answers: 4
    UPDATE hd_spare_details 
    SET Qty= Qty+1
    WHERE reg_no='998'
    I just can't help to wonder what it is you really want to do. You example doesn't make sense: one time you talk about hd_spare_detail the next time about hd_spare_details. Is that a typo or are two different tables involved?

    Can you explain - like you would explain to a total stranger who doesn't know what you are doing or why you are doing it - again what you want to do and why. Also provide some example data. If you have two tables, one to read from the other to update. Give their definitions (DDL) and some example data for both. Also give the data you want to have in all those tables at the end.
    With kind regards . . . . . SQL Server 2000/2005/2012

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  3. #3
    Join Date
    Jan 2008
    actually its hd_spare_details, there is only 1 table
    it worked ,thank you

  4. #4
    Join Date
    Jan 2008
    i have 2 tables, hd_Spare and hd_Spare_Detail
    hd_spare contain Total_Qty and hd_Spare_Detail contains Qty

    i want to select Qty from hd_spare_detail where reg_no='2'
    den add Qty into Total_Qty which is in table hd_Spare
    how to do this?
    please help me out ASAP

  5. #5
    Join Date
    Apr 2002
    Toronto, Canada
    Quote Originally Posted by rukhsar
    please help me out ASAP
    please describe your tables accurately ASAP

    first you confuse hd_Spare_Detail and hd_Spare_Details

    but you say "actually its hd_spare_details, there is only 1 table"

    then suddenly you say "i have 2 tables, hd_Spare and hd_Spare_Detail"

    and all of a sudden hd_Spare_Details has dropped the s again

    please make up your mind

    oh, and you might also describe how these two tables are related | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2008
    my last post was the other question
    i've resolved it

    thanx for concern

Posting Permissions

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