About insert sql on duplicate key update

来源:互联网 发布:鼠标自动点击器 mac 编辑:程序博客网 时间:2024/05/21 06:22

Here was a useful insert sql like this :

insert into `table` (`field1`,`field2`,`field3`) values('value1','value2','value3') on duplicate key update `id`=`id`,`count`=`count`+1;

It means if the values of field1,field2,field3 value1, value2,value3 are exist, it will update the exist row , otherwise , it will insert the row with value1, value2 ,value3.

Before use this you must set `field1`,`field2`,`field3` was unique index.

原创粉丝点击