Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

MySQL Update

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
Brogrim
Asked:
Brogrim
1 Solution
 
Tomas Helgi JohannssonCommented:
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
 
BrogrimAuthor Commented:
Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now