我只是想知道如果table1和table2中的几个值相等,如何更新table1中的行。
例如,table1有行:
id - password - attemp
user secret 0
user2 pass 0
和table2有行“
id - password
user secret
user2 kek
更新table1尝试值,其中table1用户和密码相等,table1尝试= 0,到table1尝试= 1
我做了类似这样的事情(它不起作用):
UPDATE a1
set a1.attemp = '1'
from table1 a1
JOIN table2 a2
on a1.user = a2.user AND a1.password = a2.password
WHERE
a1.attemp != 1
答案 0 :(得分:0)
试试这个:
UPDATE table1 a1
INNER JOIN table2 a2 ON a1.id = a2.id AND a1.password = a2.password
SET a1.attemp = '1'
WHERE a1.attemp != '1'
这将导致:
ID PASSWORD ATTEMP
user secret 1
user2 pass 0