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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:31:28+00:00 2026-06-08T11:31:28+00:00

I have 2 tables. I need to update data the data in tableB ,

  • 0

I have 2 tables. I need to update data the data in tableB, populate it with data from tableA.

But the problem is the design (note: I can’t change the design because its a ready made system. I’ll just have to deal with the fail).

Lets say tableA (2 columns) the data source is structured like so:

ID | NAME
1    dude
2    dud
3    bro
4    broo
5    killa
6    whale
--ID is an index and NAME is UNIQUE

Now tableB (6 columns) the destination (hard part for me):

ID1 | NAME1 | ID2 | NAME2 | ID3 | NAME3
1     dude    2     dud     3     bro
4     broo    5     killa   6     whale
--All columns here has UNIQUE data though it is not set on the design.
--and so on until the end.

Now what I want to do is UPDATE the names in tableA to the names in tableB corresponding to there ID’s.

Example:

ID from TableA is 1
Find ID=1 on TableB
If ID=1 then UPDATE the next column to 'dude'

Example end of TableA is:

ID | Name
9997 sweet
9998 jess
9999 grape
--The END

Example end of TableB is:

ID1 | NAME1 | ID2 | NAME2 | ID3 | NAME3
9997  sweet1  9998  jess1   9999  grape1
--The END

Please help me.

Note:

  • All given table names and column names are for example purposes only.
  • There are more columns in the tables, but they don’t need to be changed/altered so I did not include an example of them.
  • The reason for this is that the data in TableB has been changed and is not matching the correct data anymore.
  • So I need to repopulate TableB with the correct data, and the only source for the correct data is TableA.
  • Lastly, I am using SQL Server 2008.

—– edit ——

Here is my final query that worked perfectly:

UPDATE CHAR_INFOR
SET
    CHARID0=(SELECT CONVERT(VARCHAR,substring(char_data, 9, 16)) from CHAR_DATA0 A WHERE A.CHAR_KEY=CHAR0_KEY), 
CHARID1=(SELECT CONVERT(VARCHAR,substring(char_data, 9, 16)) from CHAR_DATA0 A WHERE A.CHAR_KEY=CHAR1_KEY), 
CHARID2=(SELECT CONVERT(VARCHAR,substring(char_data, 9, 16)) from CHAR_DATA0 A WHERE A.CHAR_KEY=CHAR2_KEY);
  • 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-08T11:31:29+00:00Added an answer on June 8, 2026 at 11:31 am

    Seems like standard SQL should work:

    UPDATE TableB B 
    SET Name1=(SELECT Name from TableA A where A.ID=ID1), 
    Name2=(SELECT Name from TableA A where A.ID=ID2), 
    Name3=(SELECT Name from TableA A where A.ID=ID3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables, I need advice on how to get data from them.
I have table 'products' and I need to update 'price' field by 20% if
I have a table that I need to update where all columns are optionally
I have one table TABLE_EXAM . i need to update the value of specific
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have 3 tables which need to be linked in an SQL statement (I'm
I have 3 tables I need to join. The contracts table is the main
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have a couple of tables that need to be be joined. The tables
I have 2 tables in a DB with very similar schemas that need 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.