title: Postgresql SELECT if string contains
body: <p>So I have a  in my Postgresql:</p>
  
  <pre><code>TAG_TABLE
  ==========================
  id            tag_name       
  --------------------------
  1             aaa
  2             bbb
  3             ccc
  </code></pre>
  
  <p>To simplify my problem,
  What I want to do is SELECT 'id' from TAG_TABLE when a string "aaaaaaaa" contains the 'tag_name'.
  So ideally, it should only return "1", which is the ID for tag name 'aaa'</p>
  
  <p>This is what I am doing so far:</p>
  
  <pre><code>SELECT id FROM TAG_TABLE WHERE 'aaaaaaaaaaa' LIKE '%tag_name%'
  </code></pre>
  
  <p>But obviously, this does not work, since the postgres thinks that '%tag_name%' means a pattern containing the substring 'tag_name' instead of the actual data value under that column.</p>
  
  <p>How do I pass the tag_name to the pattern??</p>