Ignore insertion on duplicate entry in mysql

advertisements

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 .

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

What can I do with mysql , what are all the settings needed in table .

Please advise me


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).....