I have to import some data in my database . And there are some record already exist in table, not all. So what I want to do that:
Run a php script for inserting data in table from input array
Make data_id unique ( not primary key) in mysql table
While inserting via php script if same data_id exist don't stop the execution but skip that record and process next.
something like this I want to do.
But my script stopping execution when data_id is repeated.
can anyone explain how can i handle this.
I don't want to apply check in database that id data_id is already exist then skip that record else insert because that will make page very slow.
You could use
INSERT...ON DUPLICATE KEY UPDATE or
On duplicate key ignore?
"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"
insert ignore into table (fields) values (values)