SQL Add & Subtract

Results 1 to 2 of 2

Thread: SQL Add & Subtract

  1. #1
    Join Date
    Dec 1969

    Default SQL Add & Subtract

    Is there a statement in SQL that will add or subtract a value to/from a fields current value? If I want to add 20 to a field called intNmbr in a table called tblTest, how could I do it without looking at the table first storing the value and then updating the table?

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL Add & Subtract

    I&#039;m not clear about what you want to do.<BR><BR>Do you<BR>a) want to add 20 to the value stored in the table (update the value in the table)<BR><BR>Or<BR><BR>b) want to display the value as that stored in the database but with 20 added to it<BR><BR>For option a, you need an update query like this<BR>Update tblTest SET [intNmbr] = [intNmbr] + 20<BR>You would now need a select query to display this data<BR><BR>For option b, do this<BR>Select [intNmbr]+20 As TheValue FROM tblTest<BR>You could now simply display the data from the recordset as normal using Myrs("TheValue")<BR><BR>Hope this helps

Posting Permissions

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