title: How to write sql result into csv file
body: <p>I'm having two tables like A and B. Table A having the Columns Name. Table B having the Columns Company Name.</p>
  
  <p>This is my code:</p>
  
  <pre><code>$query1 = "SELECT Name FROM A"; 
  $query2 = "SELECT Company Name FROM B"; 
  
  $statement1 = $connection-&gt;prepare($query1);    
  $statement2 = $connection-&gt;prepare($query2);
  
  $statement1-&gt;execute();
  $statement2&gt;execute();
  
  while ( ($name) = $statement-&gt;fetchrow_array) {
      push (@Name, $name);    
  } 
  while ( ($companyname) = $statement-&gt;fetchrow_array) {
      push (@companyName, $companyname);  
  }
  
  open (FH, "&gt;&gt;Output.csv") or die "$!";
  </code></pre>
  
  <p>I need to write the data in the csv file like this</p>
  
  <pre><code>Name   CompanyName
  
  xxx     yyyy
  
  xxx     yyyy
  
  xxx     yyyy
  
  xxx     yyyy
  
  xxx     yyyy
  </code></pre>