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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:44:39+00:00 2026-05-26T23:44:39+00:00

In my mysql db i’ve 2 table with same field in both. I need

  • 0

In my mysql db i’ve 2 table with same field in both.

I need to update all the records in table2 where table1 had the same id_customer and the fields are not empty.

Example:

table1

id|name|surname|id_customer|email

1|jon|jack|12|hello@me.com

table2

id_customer|name|surname|email

12| |jack|hello@me.com

The query have to update table2 adding “jon” on name

Any idea how to?

Thank you

  • 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-26T23:44:39+00:00Added an answer on May 26, 2026 at 11:44 pm

    Try this one –

    UPDATE table1 t1
      JOIN table2 t2
        ON t1.customer_id = t2.customer_id
    SET
      t2.name = IF(t2.name IS NULL OR t2.name = '', t1.name, t2.name),
      t2.email = IF(t2.email IS NULL OR t2.email = '', t1.email, t2.email),
      t2.sur_name = IF(t2.sur_name IS NULL OR t2.sur_name = '', t1.sur_name, t2.sur_name);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MySQL table with couple of fields: id - PRIMARY KEY url - CHAR(255) .
MySQL - is it legal to do 'SELECT table1.*,table2.column FROM table1,table2' ?
mysql> alter table metakey add constraint Name unique(name); mysql> desc metakey; +-------+---------------------+------+-----+---------+----------------+ | Field
MySQL 5.0.45 Table A has the following fields (columns): 1. transcation_id 2. client_name 3.
mySQL DB. Its a download log table. A user can download the same file
MySQL specifies the row format of a table as either fixed or dynamic, depending
MySQL 5.0.45 What is the syntax to alter a table to allow a column
mysql> select count(*) from table where relation_title='xxxxxxxxx'; +----------+ | count(*) | +----------+ | 1291958
MySQL allows the value of 0000-00-00 for date fields, however ActiveRecord treats an assignment
Mysql begin generate big IO. One website have many rows in session,requests table (

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.