Solved

MySQL Update

Posted on 2013-11-10
2
348 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count download link and run update query 9 82
updating the date data 12 34
I want to echo out my field names with its values into a table 10 36
Inserting data into database 10 35
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
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…

856 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