Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:09:16+00:00 2026-06-04T12:09:16+00:00

I am using DB2 for performing the below update operation. update DATA set B_DESC=P_DESC,

  • 0

I am using DB2 for performing the below update operation.

update DATA set B_DESC=P_DESC, P_DESC=null
where B_DESC= *, P_DESC=*
(Select B_DESC,P_DESC from C_DATA) 

The below is actually possible but since complex joins are involved in that sub query it is not advisable to use like below

update DATA set B_DESC=P_DESC, P_DESC=null
where B_DESC= (Select B_DESC from C_DATA), P_DESC=(Select P_DESC from C_DATA)

I have to update DATA table, but the B_DESC and P_DESC i have to fetch it from C_DATA table and use it in the UPDATE query.

Please let me know how to do it. It has to be a single query if possible.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:09:17+00:00Added an answer on June 4, 2026 at 12:09 pm

    Use a merge query to update the table, instead of join. DB2 does not accept join in update query for that purpose, you have to use a merge:

    MERGE INTO TABLE_NAME1 A 
        USING (SELECT  COL1, COL2  FROM TABLE_NAME2) B
        ON A.COL1 = B.COL2
        WHEN MATCHED AND A.COL1 = B.COL2
        THEN UPDATE SET A.COL1 = B.COL2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have problem using LIKE structure in DB2 : for example: select * from
I am using command db2 restore db S18 from /users/intadm/s18backup/ taken at 20110913113341 on
I'm using db2 version 9.7* and it seems impossible to make a NOT NULL
I want to execute multiple statements from my data access layer using C# dan
I'm using db2 export to save data to a CSV file. Ultimately I need
I am reading records from file and inserting into database. I am using DB2
I am having problem connecting to iSeries DB2 using IBM.Data.DB2.iSeries, but I can easily
As a developer using DB2 for the first time, I'm not familiar with what
I am using db2 and I want to find tables, having a column named
How do I insert to an identity column using sequences in DB2?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.