Update MySQL table and ignore duplicate entries

后端 未结 2 1218
清歌不尽
清歌不尽 2020-12-29 18:29

I created a table that contains a UNIQUE \'mobile_no\' like

09727048248
9727048248
9824578564
9898998998

Then I am going to check whether o

相关标签:
2条回答
  • 2020-12-29 18:40

    If you have declared the mobile number as the primary key in your table, then you can’t have the same mobile number twice in your table. Have a look at the MySQL UPDATE documentation.

    0 讨论(0)
  • 2020-12-29 18:52

    Use UPDATE IGNORE:

    update IGNORE bccontacts 
    set mobile_no='919727048248' 
    where mobile_no=09727048248
    

    More info here: http://dev.mysql.com/doc/refman/5.0/en/update.html

    0 讨论(0)
提交回复
热议问题