Home > Backend Development > PHP Tutorial > 怎么判断要插入的数据是否已经存在,如果存在就count+1,不存在就插入

怎么判断要插入的数据是否已经存在,如果存在就count+1,不存在就插入

WBOY
Release: 2016-06-20 12:25:41
Original
1442 people have browsed it

插入前先判断数据是否存在,如果存在就COUNT+1,不存在就插入数据怎么写
                


回复讨论(解决方案)

开启事务
select
判断是否存在
如果存在update count+1
如果不存在insert
如果成功 commit
如果失败,rollback

可以给出详细代码么? 楼主小白一个,有点头晕

如果只是查询表中的一条记录的还要用事物么?

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