在mysql中重复条目上跳过插入 [英] Skip insert on duplicate entry in mysql
问题描述
我有一个喜欢的表,其中包含一些字段,例如login_id,driver_id(一个login_id可能有很多driver_id).然后我正在使用批量更新,没有检查表中是否存在driver_id.
I have a favorite table containing some fields like login_id,driver_id(One login_id may have many driver_id) . Then I am using bulk update , not having any check the driver_id is exists in table .
输入数据将是驱动程序ID的集合,如果相关的login_id已经存在相同的ID,我需要跳过驱动程序ID的插入.因此,将插入新的ID,而不会插入其他ID
Input data will be set of driver ids , I need to skip the insertion of driver id if the same id already be there for relevant login_id . So the new ids will be inserted and others are not
我可以使用mysql做什么,表中需要做哪些所有设置?
What can I do with mysql , what are all the settings needed in table .
请告诉我
推荐答案
您可以使用"INSERT IGNORE INTO".它返回更新后的行数.
You can use "INSERT IGNORE INTO".it's return updated row count.
INSERT IGNORE INTO favorite(login_id,driver_id) VALUES (login_id,driver_id) (login_id,driver_id).....
这篇关于在mysql中重复条目上跳过插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!