我只是想知道如果 table1 和 table2 中的几个值相等,如何更新 table1 中的行。
例如, table1 有行:
id - password - attemp
user secret 0
user2 pass 0
和 table2 有行"
id - password
user secret
user2 kek
将 table1 attemp 值(其中 table1 用户和密码相等且 table1 attemp = 0)更新为 table1 attemp = 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