Home > Database > Mysql Tutorial > mysql 批量更新记录

mysql 批量更新记录

WBOY
Release: 2016-06-07 14:58:16
Original
1029 people have browsed it

replaceinto或者insertinto...onduplicatekeyupdate 可以批量更新 但是replace实际是先delete再insert,自动增长ID会变 所以建议用insertinto...onduplicatekeyupdate 无 INSERT INTO tt(id,age) VALUES (48,1),(50,2),(69,2) ON DUPLICATE KEY UPDATE age=VA

replace into 或者insert into ...on duplicate key update
可以批量更新
但是replace 实际是先delete再insert ,自动增长ID会变
所以建议用insert into ...on duplicate key update
INSERT INTO tt(id,age) VALUES  (48,1),(50,2),(69,2) ON DUPLICATE KEY UPDATE age=VALUES(age);
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template