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 8160513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:15:55+00:00 2026-06-06T18:15:55+00:00

I try to update a column in an table with the following query. In

  • 0

I try to update a column in an table with the following query. In that case 32000 Rows are updated.

Update Table72D012 t2 set DEFINING_ARGUMENT_ID = 
(
SELECT   t3.ID
FROM     Table70t3 t3,
         Table70t1 t1,
         Table70t0 t0,         
         Table4 t4
WHERE    t2.Model_id = t4.ID
AND      t3.ID = t1.PARAM_VALUE_BPVA_ID
AND      t3.VALUE_BPAR_ID = t0.ID
AND      t0.KEY='SPECIAL_KEY'
AND      t1.LANGUAGE='en'
AND      t4.Model = t1.name

);

I wanted check result and I used the following query to get the count of relevant ids. I got the result 26500.. Why are the result (count of update and count of select result) different from each other ?
How can I correct the UPDATE query?

ONLY SELECT

SELECT   t3.ID
FROM     Table70t3 t3,
         Table70t1 t1,
         Table70t0 t0,
         Table72D012 t2,
         Table4 t4
WHERE    t2.Model_id = t4.ID
AND      t3.ID = t1.PARAM_VALUE_BPVA_ID
AND      t3.VALUE_BPAR_ID = t0.ID
AND      t0.KEY='SPECIAL_KEY'
AND      t1.LANGUAGE='en'
AND      t4.Model = t1.name
  • 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-06T18:15:58+00:00Added an answer on June 6, 2026 at 6:15 pm

    First, you need to learn the correct join syntax. Doing the joins in the WHERE clause is a bad, bad idea.

    The reason is simple. The first query is updating very row in the table, because you have no WHERE clause or other condition.

    The second query is returning all the rows that match the query. In the update version, those rows will get values of NULL.

    This is the nice syntax, supported by MS SQL but not by DB2:

    Update Table72D012 t2
        set DEFINING_ARGUMENT_ID = t3.ID
        from (SELECT t4.id as t4_id, t3.ID
              FROM Table70t3 t3 join 
                   Table70t1 t1
                   on t3.ID = t1.PARAM_VALUE_BPVA_ID join
                   Table70t0 t0
                   on t3.VALUE_BPAR_ID = t0.ID join
                   Table4 t4 
                   on t4.Model = t1.name
              WHERE t0.KEY='SPECIAL_KEY' AND t1.LANGUAGE='en'
              ) t
        WHERE t2.Model_id = t4_ID
    

    I don’t think DB2 allows the FROM clause in an UPDATE, so you need something like this:

    Update Table72D012 t2
        set DEFINING_ARGUMENT_ID = 
             (SELECT t3.ID
              FROM Table70t3 t3 join 
                   Table70t1 t1
                   on t3.ID = t1.PARAM_VALUE_BPVA_ID join
                   Table70t0 t0
                   on t3.VALUE_BPAR_ID = t0.ID join
                   Table4 t4 
                   on t4.Model = t1.name
              WHERE t0.KEY='SPECIAL_KEY' AND t1.LANGUAGE='en' and t2.Model_id = t4.ID
              ) 
        WHERE exists              
             (SELECT t3.ID
              FROM Table70t3 t3 join 
                   Table70t1 t1
                   on t3.ID = t1.PARAM_VALUE_BPVA_ID join
                   Table70t0 t0
                   on t3.VALUE_BPAR_ID = t0.ID join
                   Table4 t4 
                   on t4.Model = t1.name
              WHERE t0.KEY='SPECIAL_KEY' AND t1.LANGUAGE='en' and t2.Model_id = t4.ID
              ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a SQL query that is similar to the following form: SELECT col1,
I am using SQL Server 2000. When I try to update a column of
I try to update a table using another table. I get the error number
I have a DAO class which I'm using to try select/update/insert with hibernate and
I've got a MySQL query somewhat like the following: SELECT * FROM products LEFT
There's a column on one of my tables that's being updated by various INSERT/DELETE
I have the following query SELECT interview_content.title `title`, gallery_images.img_path img FROM `interview`, `interview_content`, `gallery`,
I have the following FluentNHibernate mapping: public AssetMap() { Table(PRASSET); Id(x => x.Id).Column(PRA_RECNUM).GeneratedBy.Sequence(PRA_RECNUM_GEN); ...fields
I have the following table holding virtual money for weekly tournaments: # select *
I try to update my profile image and use this code: $connection->post('account/update_profile_image', array('image' =>

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.