使用insert ignore来避免向数据库重复插入数据

  mysql中 insert ignore 的使用示例如下:

  INSERT IGNORE INTO `table_name` (`reportid`, `content`) VALUES (‘11111’,‘hello’);

  需要注意的是,如果对应的表没有加唯一索引或者相应主键的话,insert ignore是不起作用的。

posted @ 2017-12-29 14:45  罗曼骑士  阅读(2122)  评论(0编辑  收藏  举报