title: How to escape underscores in Postgresql
body: <p>When searching for underscores in Postgresql, literal use of the character <code>_</code> doesn't work. For example, if you wanted to search all your tables for any columns that ended in <code>_by</code>, for something like change log or activity information, e.g. <code>updated_by</code>, <code>reviewed_by</code>, etc., the following query almost works:</p>
  
  <pre><code>SELECT table_name, column_name FROM information_schema.columns
  WHERE column_name LIKE '%_by'
  </code></pre>
  
  <p>It basically ignores the underscore completely and returns as if you'd searched for <code>LIKE '%by'</code>. This may not be a problem in all cases, but it has the potential to be one. How to search for underscores?</p>