If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Update a single column in a row in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-11, 18:10
valgrom valgrom is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
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.
Reply With Quote
  #2 (permalink)  
Old 07-14-11, 18:16
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 07-14-11 at 18:22.
Reply With Quote
  #3 (permalink)  
Old 07-14-11, 18:54
valgrom valgrom is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
I will try these and report back if they are not successful.

Thanks for the help.

Mike
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On