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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:54:20+00:00 2026-05-28T13:54:20+00:00

I have the table: select * from person; +—-+——+———+ | id | name |

  • 0

I have the table:

select * from person;

+----+------+---------+
| id | name | surname |
+----+------+---------+
|  1 | John | Doe     |
|  2 | Mary | Smith   |
+----+------+---------+
2 rows in set (0.00 sec)

I need to replace values in a MySQL database. All the values have the same id, so I´m trying:

replace into person (id,name) values (1,'Victor');

select * from person;
+----+--------+---------+
| id | name   | surname |
+----+--------+---------+
|  1 | Victor | NULL    |
|  2 | Mary   | Smith   |
+----+--------+---------+
2 rows in set (0.00 sec)

The problem is it´s setting the surname as NULL.

I know I can do it with an UPDATE person SET name='Victor' WHERE id=1 but I have a huge SQL file with a dump containing many INSERT INTO, so i´m thinking on useing REPLACE INTO because has the same syntaxis and it would be faster, just doing a search&replace (INSERT -> REPLACE INTO).

Edit:
The problem is I have a huge dump file like this:

INSERT INTO person (id,name) VALUES (1,'Victor');
INSERT INTO person (id,name) VALUES (2,'Mark');
INSERT INTO person (id,name) VALUES (3,'Steve');
INSERT INTO person (id,name) VALUES (4,'Lou');
INSERT INTO person (id,name) VALUES (5,'Jessica');

etc..

So I´m looking the easiest way to update all those names into the database. It would be great if I could do something like this: UPDATE person SET (id,name) VALUES (1,´Victor')

  • 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-28T13:54:21+00:00Added an answer on May 28, 2026 at 1:54 pm

    Ideally you would use something like this:

    INSERT INTO person (id, name) values ('1', 'Victor') 
    ON DUPLICATE KEY UPDATE name = 'Victor';
    

    The reason REPLACE INTO doesn’t achieve the results you want is because REPLACE INTO, in terms of functionality, deletes the row and re-inserts it with the data you provided.

    If your database dump contains all the info already in your database, plus updated info, you’re better off just dropping your tables and running the import on a clean db. If there is data stored in your database that isn’t contained in the dump, then the import is too blunt an instrument to work with.

    You may have luck whacking ON DUPLICATE KEY UPDATE name = 'foo'; at the end of every statement.

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

Sidebar

Related Questions

If I have two queries SELECT Id, Forename, Surname FROM Person WHERE PersonName Like(‘%frank%’)
Suppose we have this person table id name gender 1 John male 2 Kurt
I have Table A. How can I select from Table A to get Table
i have users table and i have posts table i want select from users
Let's say I have a table: SELECT SUM(quantity) AS items_sold_since_date, product_ID FROM Sales WHERE
I have a table with sales per store as follows: SQL> select * from
I need a select from table which does not have column that tells when
I have a query like so : SELECT * FROM table WHERE premium =
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a Tabular type Form based upon a SELECT * FROM table type

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.