I am trying to update ‘pwd’ column of ‘Goal’ table using following mysql query but sad thing is it gives error. mysql query:
UPDATE Goal
SET pwd = (SELECT MD5(CONCAT(ID, LEFT(phone,3), '$='))
FROM Esubmission);
error:
1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FROM Esubmission)’ at line 1
My tables are like below;
Esubmission
ID | pnone | email |
--------------------------------------------
20378 | 00000000000 | someone@gmail.com|
20379 | 00000000000 | someone@gmail.com|
20380 | 00000000000 | someone@gmail.com|
Goal
usr | pwd | time|
--------------------
20378 | |12:09|
20379 | |15:29|
20380 | |15:47|
Hmm…. I’m thinking that you really want to set the password for each user (I think), in which case you’ll need to have a join for the update, and that way you can eliminate your multiple values you are selecting.. because the way you have it, you’re updating all the values in the Goal table for pwd to the same value… the way below, you update each users pwd to be based on the row joined with the ID. Assuming you have one row for each usr in the esubmission table, this should work: