Solved

MySql Inner Join Update Query

Posted on 2013-12-26
6
761 Views
Last Modified: 2014-01-02
I have a meta field for a WordPress user called business_website that holds the company url. I need to update the user_url file in the wp_users table with the value from this business_website meta field.

I can construct a simple update query but since this needs some kind of join I'm unsure.

Please help.
0
Comment
Question by:webdork
  • 3
  • 3
6 Comments
 
LVL 41

Accepted Solution

by:
Sharath earned 500 total points
ID: 39741072
Do you have business_website in another table. If both columns in  same table, you can try this.

Update wp_users
      Set user_url = business_website

If business_website is in another table, what is the joining condition between both the tables. If you know, you can try like this.

Update wp_users t1
    Join  OtherTable t2
      On t1.Col = t2.Col
      Set t1.user_url = t2.business_website
0
 

Author Comment

by:webdork
ID: 39741155
yes another table: wp_usermeta the linking fields are as follows:


linkage fields
wp_usermeta:user_id
wp_users:id

date fields
wp_usermeta:business_website
wp_users:user_url

I'd like to add a where clause to test before I change 500 records.
where id=123
0
 
LVL 41

Expert Comment

by:Sharath
ID: 39742280
Update wp_users t1
    Join  wp_usermeta t2
      On t1.id = t2.user_id
      Set t1.user_url = t2.business_website
where t1.id = 123;
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:webdork
ID: 39742492
Update wp_users t1

Or

Update t1.wp_users
0
 
LVL 41

Expert Comment

by:Sharath
ID: 39743935
Update wp_users t1

Run the command and let me know if you get any error.
0
 

Author Closing Comment

by:webdork
ID: 39752082
lovely, thank you.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question