title: MySql: Upload CSV data into Temporary Table and Then join
body: <p>I am facing a very weird problem with Mysql query. I am not sure if I am doing it right or not. I have tried crawling the web for a legitimate solution but couldn't find anything.</p>
  
  <p>I have 1 table, say something as follow:</p>
  
  <p><strong>Table Foo</strong></p>
  
  <pre><code>ID | Col1 | Col2
  -------------------------
  1  | abc  | ABC1234567675
  2  | def  | ABC3435345345
  </code></pre>
  
  <ul>
  <li>ID is of type Int</li>
  <li>Col1 is Varchar(50)</li>
  <li>Col2 is an Alpha numeric string of type varchar(200)</li>
  </ul>
  
  <p>I have a CSV file which has only 1 column, which has same values like Col2 of Foo table above.</p>
  
  <p>I am loading the CSV into the Temporary table, let's say Bar using the queries as follows:</p>
  
  <pre><code>drop temporary table Bar;
  
  CREATE TEMPORARY TABLE Bar (
    Col2 varchar(200)
  );
  
  
  LOAD DATA LOCAL INFILE 'C:/update.csv'
  INTO table Bar;
  </code></pre>
  
  <p>When I do a Select * on the Temp Table Bar. It lists all the values it has uploaded from the CSV into the temp table.</p>
  
  <p>But when i try to join it on Col2. It is returning only 1 result.</p>
  
  <p>Whereas when i manually query the table Foo with a where clause using the Col2 values from the Table Bar. It is showing many records exists in table Foo.</p>
  
  <p>I have tried below queries:</p>
  
  <pre><code>select * from Foo inner join Bar on Foo.Col2=Bar.Col2;
  
  select * from Foo join (select Col2 from Bar) b on Foo.Col2=b.Col2;
  
  select * from Foo where Col2 in (select Col2 from Bar);
  </code></pre>
  
  <p>But all three of them returns only 1 result.
  Had anyone else also faced similar problem in the past?
  Could you guide me to what I am doing wrong?</p>
  
  <p>Any help would be appreciated.</p>