Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Unanswered: Update a single column in a row in DB2

    I'm a newbie to SQL in general and the searches I've done here haven't given me the right answer so I thought it would be worth posting this.

    I have a DB2 table with multiple rows and columns. I'm trying to write an SQL statement that will allow me to update a single column in a specific row in that table.

    I can't seem to find the correct syntax for the DB2 update command.

    example:

    update COLUMN2 of ROW1 in TABLE1 where COLUMN1="a specific value that I will provide"

    any help would be appreciated.

    Thanks.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    update TABLE1 set COLUMN2 = 'X' where COLUMN1= 'Y'

    If the columns are defined as numeric data types, then omit the single quotes. In order to ensure that only one row is updated, COLUMN1 would have to contain unique values (preferably have a unique index or PK defined on the column).
    Last edited by Marcus_A; 07-14-11 at 19:22.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Jul 2011
    Posts
    2
    I will try these and report back if they are not successful.

    Thanks for the help.

    Mike

  4. #4
    Join Date
    Jul 2014
    Posts
    4
    closed and moved to new thread.
    Last edited by vijayabaskar; 07-30-14 at 10:02.

Posting Permissions

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