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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:58:49+00:00 2026-05-14T22:58:49+00:00

So I have a table of data that is 10,000 lines long. Several of

  • 0

So I have a table of data that is 10,000 lines long. Several of the columns in the table simply describe information about one of the columns, meaning, that only one column has the content, and the rest of the columns describe the location of the content (its for a book). Right now, only 6,000 of the 10,000 rows’ content column is filled with its content. Rows 6-10,000’s content column simply says null.

I have another table in the db that has the content for rows 6,000-10,000, with the correct corresponding primary key which would (seemingly) make it easy to update the 10,000 row table.

I have been trying an update query such as the following:

UPDATE table(10,000)
SET content_column = (SELECT content FROM table(6,000-10,000) WHERE table(10,000).id = table(6-10,000.id)

Which kind of works, the only problem is that it pulls in the data from the second table just fine, but it replaces the existing content column with null. So rows 1-6,000’s content column become null, and rows 6-10,000’s content column have the correct values…Pretty strange I thought anyway.

Does anybody have any thoughts about where I am going wrong? If you could show me a better sql query, I would appreciate it! Thanks

  • 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-05-14T22:58:49+00:00Added an answer on May 14, 2026 at 10:58 pm

    The reason is that you have no Where clause so all rows are being updated. The following query will only update tows that exist in the 6K-10K table, but will still overwrite matching values.

    Update table(10,000)
    Set content_column =    (
                            Select content 
                            From table(6,000-10,000) 
                            Where table(10,000).id = table(6-10,000.id)
                            )
    Where Exists    (
                    Select 1
                    From table(6,000-10,000) 
                    Where table(10,000).id = table(6-10,000.id)
                    )
    

    Another way, if you simply do not want to overwrite the existing values would be to use Coalesce:

    Update table(10,000)
    Set content_column =    Coalesce(table(10,000).content_column
                                ,   (
                                    Select content 
                                    From table(6,000-10,000) 
                                    Where table(10,000).id = table(6-10,000.id)
                                    ))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my data base that has three columns: Screen, Icon,
I have a table that has 5,000(table1) lines in it. Currently, 3,000 of them
I have table of data that is sorted as follows: Item | Sample |
I have a table of data that I need to dynamically add a column
I have a table of data that is being sorted alphabetically, and it's a
I have a table that stores data that has been entered regarding the amount
I have table to test score data that I need to pivot and I
I have a large table of data (that displays test data) that is separated
I have table with column Percentage varchar(10) Data in that table is Pecentage 2/10
I have a table with a lot of repeated data that I'd like to

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.