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

  • Home
  • SEARCH
  • 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 8678045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:36:43+00:00 2026-06-12T20:36:43+00:00

I am trying to update multiple rows with different values, but don’t need to

  • 0

I am trying to update multiple rows with different values, but don’t need to match any specific ID.

Of course, both columns on two different tables will have a same number of records.

Example, I have a table Table1 and Column1 and a query with list 10 items in that table (the ID is not consecutive).

ID  ItemName
1    Item1
2    Item2
4    Item3
5    Item4
6    Item5
8    Item6
9    Item7
14    Item8
18    Item9
23    Item10

Now, I have another table Table2 and Column2 that I want to update with those 10 items above.

This also has different IDs, but ItemName is blank/null value.

ID   ItemName
301    NULL
321    NULL
323    NULL
331    NULL
333    NULL
335    NULL
336    NULL
355    NULL
377    NULL
388    NULL

So, I a looking for a query where I can update the Table2 and Column2 with those 10 items from Table1, and the result looks like this

ID   ItemName
301    ITem1
321    ITem2
323    ITem3
331    ITem4
333    ITem5
335    ITem6
336    ITem7
355    ITem8
377    ITem9
388    ITem10

Please help. 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-12T20:36:44+00:00Added an answer on June 12, 2026 at 8:36 pm
    WITH CTE1
         AS (SELECT *,
                    Row_number() OVER (ORDER BY ID) AS RN
             FROM   Table1),
         CTE2
         AS (SELECT *,
                    Row_number() OVER (ORDER BY ID) AS RN
             FROM   Table2)
    UPDATE CTE2
    SET    ItemName = CTE1.ItemName
    FROM   CTE2
           JOIN CTE1
             ON CTE1.RN = CTE2.RN 
    

    SQL Fiddle

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

Sidebar

Related Questions

I can't seem to find this anywhere, but I'm trying to update multiple rows
I'm trying to update multiple rows in a table but due to server resources
I have the following SQL statement where i'm trying to update multiple rows matching
I'm trying to update multiple rows in one table in MySQL database by doing
I am trying to update multiple rows here.However I fail to point the right
I am trying to insert huge multiple rows in a single transaction. But the
I am trying to update several rows from data of a specific row THIS
I am trying to update multiple rows at once (SQL Server 2005). Previously I
I am trying to update multiple rows in one table, based on a select
I am trying to update multiple rows on one table using MySQL. I have

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.