Jump to content

Avoid insert duplicate emails when importing from CSV file


Recommended Posts

Hi, I need to insert to my email database new emails in CSV format, but I don't want to import duplicate emails.

 

 

Table Scheme:

 

id | email  (unique) | name

---------------------------

1 | expl1@mail.com | expl1

2 | expl2@mail.com | expl2

3 | expl3@mail.com | expl3

4 | expl4@mail.com | expl4

 

How can I import to this database new emails without insert duplicate emails?

 

The function LOAD DATA INFILE can do this, avoiding to insert duplicate emails in the UNIQUE field "email"?

 

Best Regards, André.

Hi,

 

Thanks for your reply.

 

I don't explain me well. The email field is "unique", but I need to import data to this database and I know that some emails that I will import are duplicated, but because the field email is "unique" I think the import will stop with an error every time that one duplicate email is inserted(or tried to insert).

 

What I need to know is... there is some way do to this:

 

"if email allready in database, ignore that email and continue importing".

 

There is a way to do this, some mysql function?

 

Best Regards, André.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.