Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:41:44+00:00 2026-06-12T12:41:44+00:00

I have some data in a csv file and I want to insert it

  • 0

I have some data in a csv file and I want to insert it into a Mysql table. My question is how to do that in a way that no duplicate values inserted into the table. I have looked at the following reference http://dev.mysql.com/doc/refman/5.1/en/load-data.html and there is a keyword IGNORE but can’t see how to use it to insert unique values only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:41:45+00:00Added an answer on June 12, 2026 at 12:41 pm

    Add unique index on the table using one or more columns:

    CREATE TABLE `test` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `start` VARCHAR(10) DEFAULT NULL,
    `end` VARCHAR(10) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `start` (`start`,`end`)
    ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
    

    You would use ignore to skip rows that error out due to duplicate index error.

    INSERT IGNORE into test (id, start, end) values (1,'test','test');
    

    Using load:

    LOAD DATA INFILE 'file_name' IGNORE INTO TABLE test;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some questions about importing data from Excel/CSV File into SQL Server. Let
I have some code to write data into a CSV file, but it writes
I have a CSV file that has rows, where data for some columns only
I have data from a CSV file that's already loaded into memory. So I
I have a huge set of data that I want to insert into the
I have a problem, when I want get some data from CSV file to
I have a large CSV file (5.4GB) of data. It's a table with 6
I am trying to create a csv file of some data. I have wrote
I have a CSV file containing some user data it looks like this: 10333,,an.10,Kenyata,,Aaron,,,,,,,,,,
I have a time series(a csv file) data that looks like below. Each observation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.