Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building an app to import data from a text file to a database.

I want to import only specific lines from the text file. With Navicat I found that we could limit number of line when importing data.

I also found an article saying that we could limit it, so I tried this:

load data infile 'c:/coop/wkwk.txt' into table jo fields 
    terminated by '|' lines terminated by '\n' limit 10,100;

But I get an error in SQL syntax, what is the QUERY to make this work?

share|improve this question

If you are using Unix/Linux you could try using a fifo buffer:

mkfifo /tmp/mysql.pipe 
# Select rows 101 to 110
sed -n 101,110p filename > /tmp/mysql.pipe & 
mysql –uusername -p -Ddatabasename -e "LOAD DATA LOCAL INFILE ' /tmp/mysql.pipe ' INTO TABLE tablename"

rm -f /tmp/mysql.pipe
share|improve this answer
This is a very bold answer. +1 because I like bold !!! – RolandoMySQLDBA Sep 10 '12 at 17:21

You can't use LIMIT on LOAD DATA INFILE. The only thing you can do, with regard to your question, is to skip a certain number of rows:


But you then have no way stopping until the end of file. See documentation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.