より明確にするために:
テーブルテーブルに (id int, username varchar(30), password varchar(30), last_successful_login timestamp, last_unsuccessful_login timestamp, another_variable varchar(30))は次の行があります:(1、 "tgh"、 "pass"、0、0、 "another")
1)間違ったユーザー/パスのペアですが、ユーザー名の行があります
すべての行の列をANDでselect id from thetable where username="tgh" and password="wrongpass" and another_variable="another";更新したいと思います(これは一意であり、( "tgh"、 "another")のペアで2つの行を使用することはできません。ただし、( "tgh"、 "another2")を使用することはできます)。 )から。last_unsuccessful_loginusername="tgh"another_variable="another"CURRENT_TIMESTAMP
したがって、例の行は(1, "tgh", "pass", 0, CURRENT_TIMESTAMP, "another")、完全に一致しない「select」クエリの後のようになります。
さらに明確にするために、私は、テーブル上でのみ、つまりusername="tgh"、選択の結果に応じて、余分な更新を実行しないようにしています。another_variable="another"update thetable set last_unsuccessful_login=CURRENT_TIMESTAMP where username="tgh" and another_variable="another";
2)正しいユーザー/パスペア
また、3つすべてとが一致する場合usernameはpassword、another_variable今回はをに設定last_successful_loginしCURRENT_TIMESTAMPます。
これにより、行の例は `(1、" tgh "、" pass "、CURRENT_TIMESTAMP、0、" another ")になります。
これを行うための最も効率的な方法は何ですか?