Solved

ignore duplicate entries with sql loader?

Posted on 2008-10-24
2
1,043 Views
Last Modified: 2010-04-21
HI, I have a table that has a primary key column. I need to enter some values into this table using sql loader (this table has existing data in it). When uploading these new values if a duplicate row is encoutered I need the loader to ignore that record and continue to load the remaining data. How can this be done? The script I am using is
load data infile 'c:/channel_lineups/load/states.txt'into table `state` (state_id, state_name, id);
where state_id is the primary key.

Thanks for the help.

A
0
Comment
Question by:aej1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Umesh earned 100 total points
ID: 22798608
Try this...

LOAD DATA INFILE  'c:/channel_lineups/load/states.txt' IGNORE into table `state` (state_id, state_name, id);

Make use of IGNORE keyword in the LOAD statement. If you specify IGNORE, input rows that duplicate an existing row on a unique key value are skipped.

BTW, you can check the syntax..

http://dev.mysql.com/doc/refman/5.0/en/load-data.html
0
 

Author Closing Comment

by:aej1973
ID: 31509742
Excellent, thank you very much.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question