Last active
January 7, 2019 12:30
-
-
Save diaolizhi/8bab65ceff8a0e10189ed2c6b02b1744 to your computer and use it in GitHub Desktop.
mysql 插入数据时如果存在主键则只更新
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Insert("INSERT INTO t_email_link VALUES (#{email}, #{link}, DATE_ADD(CURDATE(), INTERVAL 2 DAY))" + | |
"ON DUPLICATE KEY UPDATE link=#{link}, exp=DATE_ADD(CURDATE(), INTERVAL 2 DAY)") | |
void saveEmailAndChangePasswordLink(@Param("email") String email, @Param("link") String link); | |
//重点是 ON DUPLICATE KEY UPDATE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment