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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:30:55+00:00 2026-06-18T10:30:55+00:00

I need to update specific columns only when there are specific cases valid. However,

  • 0

I need to update specific columns only when there are specific cases valid.
However, the below is updating everything in my table.
I am nesting the table itself, as I have to self-update the table.

Query1 that updates everything:

UPDATE TestTable m 
 SET m.column1 =  'VALUE2' -- I don't need any nested column data, I specifically know the data needs to UPDATE from 'Value1' to 'Value2' for filtered rows from nested Query
 WHERE EXISTS
  (
    SELECT  1 
        FROM TestTable m1
        WHERE
        m1.column2='xyz'
        AND (
         m1.nameColumn IN ('%ME%','%MYSELF%')  --- This is not really used, I am just saying I have additional filters.        
        )
        AND ( m1.column1 = 'VALUE1' OR   m1.column1 IS NULL ) -- We need to update the records which have 'VALUE1' column1 only..  

  )

Query 2: Also does the same….

    UPDATE TestTable m 
     SET m.column1
     = (
        select 'VALUE2'   -- Like example1, I don't need the nested table's data at all.
-- I need the nested query to filter out rows to let the outer query know that only those rows are to be updated
           FROM TestTable m1
            WHERE
            m1.column2='xyz'
            AND (
             m1.nameColumn IN ('%ME%','%MYSELF%')  --- This is not really used, I am just saying I have additional filters.        
            )
            AND ( m1.column1 = 'VALUE1' OR   m1.column1 IS NULL ) -- We need to update the records which have 'VALUE1' column1 only..  
      )
      --WHERE m1.column1 != m.column1 --- THIS DOESN'T WORK, this is an added check that I don't update where it is not needed. It can be removed/ignored
  • 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-18T10:30:56+00:00Added an answer on June 18, 2026 at 10:30 am

    I don’t understand why you wouldn’t just use a straightforward where clause on the update:

    UPDATE TestTable m SET m.column1 = 'VALUE2'
    WHERE (m.column1 IS NULL OR m.column1 = 'VALUE1')
    AND m.nameColumn IN ('ME', 'MYSELF')
    AND m.column2 = 'xyz';
    

    …am I missing something obvious?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table TABLE_EXAM . i need to update the value of specific
I need to update the Notes field in my table tblMain by concatenating the
I want to update rows of a table in a specific order, like one
I need to update status line editor-specific information. I already have my own implementation,
I have the following table: http://kimag.es/share/59074317.png columns = [id cid comment] I need a
I need to update cells within a specific column based upon ids in another
I need to update the next column to the column that contains an specific
Hi if want to update some specific columns of a row so should i
I have a table called customers_shipto with columns (ID,shiptonick,address) I need to auto populate
I need to update my .htaccess file to redirect permanently all URLs from http://example.com/pages/5604/article/something/?page=299

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.