Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mysql - Load data infile query

 
Carl John
Ranch Hand
Posts: 47
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic