Sample Header Ad - 728x90

Update a table with data from another table

0 votes
2 answers
162 views
I have a Wordpress table in which I want to take the user_email from **Table2** and import it to contact_email on **Table1** one based off of the user_login. user_login and user_id equal the same value. Nothing I have tried has worked. Any thoughts? Table1 ----------------------------------- user_id|contact_email |contact_name ======================================= 123 |test@test.com |deft 124 |test3@test.com|deft3

Table2 (User table) ----------------------------------- user_login|user_email |display_name ======================================= 123 |test@test.com |deft 124 |test3@test.com |deft3 I have tried: UPDATE Table1 SET contact_email = (SELECT Table2.user_email FROM Table2 WHERE Table2.user_login = user_id ) WHERE EXISTS (SELECT Table2.user_email FROM Table2 WHERE Table2.user_login = user_id );
Asked by Deft Tech (1 rep)
Mar 30, 2018, 05:36 PM
Last activity: Jul 7, 2025, 07:00 AM