title: Perl query and get column name
body: <p>I need to make a query where I will be looking for a specific string through several columns and I need to know which column (name) contains the value that I need.</p>
  
  <p>In the example below I need a query where I can ask which column contains the value 1000000000002101214 and that it returns f1. DB is MySQL and I need the programming to be done in Perl.</p>
  
  <pre><code>+---------------------+---------------------+---------------------+
  | f1                  | f2                  | f3                  |
  +---------------------+---------------------+---------------------+
  | 1000000000002101214 | 1000000000001989129 | 1000000000001881637 |
  | 1000000000002080453 | 1000000000001968481 | 1000000000001862284 |
  | 1000000000002085919 | 1000000000001973677 | 1000000000001866854 |
  | 1000000000002075076 | 1000000000001963189 | 1000000000001857288 |
  +---------------------+---------------------+---------------------+
  </code></pre>
  
  <p>I was able to find an almost-answer to my question from another site where I could get the column names of the fields in the table with the following:</p>
  
  <pre><code>my @cols = @{$sth-&gt;{NAME}}; # or NAME_lc if needed 
  
  while (@row = $sth-&gt;fetchrow_array) {
      print "@row\n";
  }
  $sth-&gt;finish;
  
  foreach ( @cols ) {
      printf( "Note: col : %s\n", $_ );
  }
  </code></pre>
  
  <p>The problem is partially resolved. In the example table I provided in the original question I needed to know on which column my answer resides, the query contains several OR statemens:</p>
  
  <pre><code>SELECT * FROM table WHERE (f1='1000000000002101214' OR f2='1000000000002101214' OR f3='1000000000002101214')
  </code></pre>
  
  <p>And I need the result to show that the column name where the number is located is f1. So....</p>
  
  <p>Any thoughts?</p>