用户工具

站点工具


sql:sql
  DELETE e1 FROM EMPLOYEE e1, EMPLOYEE e2 WHERE e1.name = e2.name AND e1.id > e2.id;
ALTER TABLE `student` CHANGE `entry_date` `temp_entry_date` timestamp NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE `student` ADD `entry_date` DATETIME NOT NULL default '0000-00-00 00:00:00';
UPDATE `student` SET `entry_date` = `temp_entry_date`;
ALTER TABLE `student` DROP `temp_entry_date`;
  • 合并数据
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6)
  ON DUPLICATE KEY UPDATE c=VALUES(c);
<insert id="insertOrUpdate">
        INSERT INTO t1 (a,b,c) 
        values
        <foreach collection="list" item="item"  separator=",">
            (#{item.a},#{item.b},#{item.c})
        </foreach>
        ON DUPLICATE KEY UPDATE c=values(c),b=values(b)
</insert>
long insertOrUpdate(List<Test> list);
sql/sql.txt · 最后更改: 2021/09/17 11:32 由 admin