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 6928259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:47+00:00 2026-05-27T11:09:47+00:00

I want to load the data from text file to database, if data already

  • 0

I want to load the data from text file to database, if data already exists i need to escape that data while loading.

I am using below query to load the data from text file to mysql data base.

“Load data infile ‘F:/wbrdata.txt’ into table wbrdatatable
fields terminated by ‘,’
optionally enclosed by “”
lines terminated by ‘\r\n’
Ignore 1 lines (channel, time, pulserate, dwellid, targetid);”

It is appending the data to existing table data. I want to avoid the common data which is already exists(duplicates) in table & file while loading to the database.

How can i achieve this?
thank you

regards
sankar

  • 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-05-27T11:09:48+00:00Added an answer on May 27, 2026 at 11:09 am

    Try to load text file into the temporary table (the same as target table), then remove duplicates from the temporary table and copy the rest to the target table.


    Example (suppose that wbrdatatable_temp is a temporary table with all data from text file):

    CREATE TABLE wbrdatatable(
      id INT(11) NOT NULL AUTO_INCREMENT,
      column1 VARCHAR(255) DEFAULT NULL,
      PRIMARY KEY (id)
    );
    
    INSERT INTO wbrdatatable VALUES 
      (1, '111'),
      (2, '222'),
      (3, '333'),
      (4, '444'),
      (5, '555');
    
    CREATE TABLE wbrdatatable_temp(
      id INT(11) NOT NULL AUTO_INCREMENT,
      column1 VARCHAR(255) DEFAULT NULL,
      PRIMARY KEY (id)
    );
    
    INSERT INTO wbrdatatable_temp VALUES 
      (1, '111'),
      (2, '222'),
      (10, '100'), -- new record that should be added
      (11, '200'); -- new record that should be added
    
    -- Copy only new records!
    INSERT INTO wbrdatatable
    SELECT t1.* FROM wbrdatatable_temp t1
      LEFT JOIN wbrdatatable t2
        ON t1.id = t2.id AND t1.column1 = t2.column1
    WHERE t2.id IS NULL;
    
    -- Test result
    SELECT * FROM wbrdatatable;
    +----+---------+
    | id | column1 |
    +----+---------+
    |  1 | 111     |
    |  2 | 222     |
    |  3 | 333     |
    |  4 | 444     |
    |  5 | 555     |
    | 10 | 100     | -- only new record is added
    | 11 | 200     | -- only new record is added
    +----+---------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load data from a text file on my server using the
I want to load a static text file from an HTML document without using
Why doesn't this code want to load all the values from a text file?
I have a form with a DataGridView and I want to load data from
I want to load some data from mysql into my cocoa application view before
I want to load the data into session so that when the next button
When I load data in my code-behind, I find that often I want to
I want to save and load my xml data using XmlReader. But I don't
I want to load some images into my application from the file system. There's
I want jQuery to periodically load a text file located on my server into

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.