Home  >  Article  >  Backend Development  >  PHP+MYSQL插入数据 检查是否重复,该如何解决

PHP+MYSQL插入数据 检查是否重复,该如何解决

WBOY
WBOYOriginal
2016-06-13 10:14:191217browse

PHP+MYSQL插入数据 检查是否重复
PHP+MYSQL插入数据 检查是否重复 是从excel里面导入的数据 别人新导入的可能会跟已有的数据重复 用的PHP-ExcelReader导入的

------解决方案--------------------
修改一下数据表就行了:
把你认为可能会存在重复的字段 设置为“UNIQUE”索引,这样就可以避免重复了。

------解决方案--------------------
select count(*) from tbl_name group by 不允许重复的字段

结果大于 1 ,就表示有重复
------解决方案--------------------
表中filename字段已经有重复数据了。创建唯一索引失败。

Statement:
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