title: Convert hex to binary in MySQL
body: <p>Currently I search a function in MySQL to do conversion between hex string to binary representation, example:</p>
  
  <pre><code>0000 -&gt; 0000000000000000
  00AA -&gt; 0000000010101010
  FFFF -&gt; 1111111111111111
  </code></pre>
  
  <p>I have already tried</p>
  
  <pre><code>UNHEX('00AA')
  CAST('00AA' AS BINARY)
  CONVERT('00AA', BINARY)
  </code></pre>
  
  <p>but didn't get the results I want.</p>