There are two tables with data:

tblUsers: login, hash, pass

tblPassHash: pass, hash

It is necessary in the tblUsers.pass field of the first table (now it is empty) to substitute the value of tblPassHash.pass (from the second, corresponding field), provided that hash from the first = hash from the second

Please tell me how

    1 answer 1

     UPDATE tblUsers t1, tblPassHash t2 SET t1.pass = t2.pass WHERE t1.hash = t2.hash 

    Not sure if the first option works specifically in sqlite. If not, a second, less beautiful one will definitely work:

     UPDATE tblUsers SET pass = ( SELECT tblPassHash.pass FROM tblPassHash WHERE tblPassHash.hash = tblUsers.hash ) 
    • In both examples, swears on the aliases (aliases) of the tables = ( - Robert
    • try to remove or rename aliases, and replace them in appeals. And how does he swear that he writes? - Grulex
    • Now in the first case, it swears at comma when listing tables after UPDATE. In the second case, without errors, it worked like this UPDATE tblUsers SET pass = (SELECT tblPassHash.pass FROM tblPassHash WHERE tblPassHash.hash = tblUsers.hash) - Robert
    • Thank you very much for the help! Now I would have to grasp, otherwise I already started to gossip about joins in update - Robert
    • During the update, the lines in the first table select the desired value from the second) - Grulex