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

The Archive Base Latest Questions

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

Possible Duplicate: Update row with data from another row in the same table I

  • 0

Possible Duplicate:
Update row with data from another row in the same table

I have created table as

create table myTable (id INT, myData varchar(20));

And I have values as

insert into myTable VALUES 
(1, 'Value 1'),
(2, 'Value 2'),
(3, 'Value 3');

Now I insert row as

insert into myTable (id) values (4);

Now I want to insert data for id 4. Value for id 4 is same as id 3. SO I believe I need to use UPDATE statement.

I tried with below, however it won’t work.

 update myTable SET myData=(select myData FROM myTable WHERE id=3) WHERE id=4;

Please let me know what need to be done.

Demo at sqlfiddle

NOTE

Actually I have myData type as MEDIUMBLOB, however for demo purpose I used varchar.

  • 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-11T20:02:13+00:00Added an answer on June 11, 2026 at 8:02 pm

    In MySQL you can’t update the same table your are selecting from. That leads to the error

    You can’t specify target table ‘myTable’ for update in FROM clause

    But you can trick MySQL by creating a temp table

    update myTable
    SET myData=(select * from (select myData FROM myTable WHERE id=3) x)
    WHERE id=4;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: update one table with data from another Extreme SQL noob here. I
Possible Duplicate: How to update GUI from another thread in C#? I have form
Possible Duplicate: How to replace string in SQLite? I have a table column data
Possible Duplicate: How to update GUI from another thread in C#? My Timer event
Possible Duplicate: How to update GUI from another thread in C#? Following scenario: I
Possible Duplicate: Is there a way to automatically update application on Android? I have
Is it possible to INSERT...ON DUPLICATE KEY UPDATE into a table on the current
Possible Duplicate: C# Update Table using SqlCommand.Parameters I'm trying to update an SQL Server
Possible Duplicate: Auditing SQL Server data changes My requirements demand for each row inserted
Possible Duplicate: Why does the binding update without implementing INotifyPropertyChanged? I have WPF: <TextBlock

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.