title: If I match a text string against multiple columns, is there an easy way to know which one(s) matched?
body: <p>I'm writing an advanced search functionality that returns records where a string matches one or more out of many text columns in this table.</p>
  
  <p>Something like:</p>
  
  <pre><code>select * from some_table where (txt_1 like '%foo%') or (txt_2 like '%foo%') or...
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>select * from some_table where match (txt_1, txt_2, ...) against ('foo')
  </code></pre>
  
  <p>if I can do full-text search (not sure yet).</p>
  
  <p>My issue is, how can I know which columns actually matched 'foo'?</p>
  
  <p>For instance, if I have these records:</p>
  
  <pre><code>id  txt_1  txt_2  txt_3  txt_4
  1   'foo'  'bar'  'bar'  'foo'
  2   'bar'  'bar'  'bar'  'bar'
  3   'bar'  'foo'  'bar'  'bar'
  4   'bar'  'bar'  'bar'  'bar'
  </code></pre>
  
  <p>my query should return something like:</p>
  
  <pre><code>id  txt_1_matches  txt_2_matches  txt_3_matches  txt_4_matches
  1   1              0              0              1
  3   0              1              0              0
  </code></pre>
  
  <p>I can do this with post-processing on the simple query results, but I'd like to avoid it.
  Is there a clean, easy way to do this?</p>
  
  <p>Cheers</p>