title: MySQL Using WHERE in LOAD DATA INFILE Statement From CSV/TXT
body: <p>I have a txt file that looks like:</p>
  
  <pre><code>Col1, Col2, Col3
  1, foo0, bar0
  1, foo1, bar1
  2, foo2, bar2
  3, foo3, bar3
  </code></pre>
  
  <p>And I want to import the txt file to a database using a similar query to:</p>
  
  <pre><code>LOAD DATA INFILE '/tmp/sample.txt'
  INTO TABLE sample
  FIELDS TERMINATED BY ','
  LINES TERMINATED BY '\n'
  IGNORE 1 LINES;
  </code></pre>
  
  <p>But only want records from the txt file where Col1 has a value of 1 and I only want to use Col1 and Col2 in the sample table. How would I create a query using a WHERE clause to determine that Col1's value is 1 and then only place the first two columns from the txt into the sample table?</p>