This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Mysql - Load data infile query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Mysql - Load data infile query" Watch "Mysql - Load data infile query" New topic

Mysql - Load data infile query

Carl John
Ranch Hand

Joined: Jun 14, 2010
Posts: 47

Hi All,

I'm developing a Java swing application with back end Database MySQL . I've a screen to upload my datas to the Database using the Query like


Here the datas are like from January to June. But if i want to skip any month data or to upload only a particular month then how will i modify the above query.

In my database table , the date column is 'SLDATE'.

Any suggestions please.?

Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

According to the docs, the LOAD DATA statement doesn't have any option to filter rows based on their column values.

If the date column is first in your input file, you might perhaps be able to import a specific month by using the LINES STARTING BY clause and further tweaking, but I'd say such a solution would be too fragile.

Other than this, you'll probably have to load the contents of the file into a temporary table and then use INSERT INTO ... SELECT to select just the desired subset of rows to insert into the target table.
I agree. Here's the link:
subject: Mysql - Load data infile query
It's not a secret anymore!