Solved

MySQL Update

Posted on 2013-11-10
2
350 Views
Last Modified: 2013-11-10
I have 2 tables table1 and table2 both with identical columns and data-type

id = int
dob = date

I am trying to update all dob in table 1 based on the id of table 2

I am using the following statement

Update table1
set table1.dob = (select dob from table2
where table1.id = table2.id)
where id = 1;

Open in new window


When i run the query the the ? is displayed but it doesnt seem to procesing the statement, its just hanging. I have set to update one query so it should'nt take that long

any ideas?
0
Comment
Question by:Brogrim
2 Comments
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
ID: 39637229
Try this

Update table1
set table1.dob = (select table2.dob from table2
where table1.id = table2.id limit 1)
where table1.id = 1;

Regards,
   Tomas Helgi
0
 

Author Closing Comment

by:Brogrim
ID: 39637394
Thanks
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
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
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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