aspose file tools*
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Mysql - Load data infile query" Watch "Mysql - Load data infile query" New topic
Author

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.?


CJohn
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

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: http://aspose.com/file-tools
 
subject: Mysql - Load data infile query