title: How to use LIKE operator with binary ordered-time UUID
body: <p>I have a MySQL 5.7 table with a binary(16) id column used as PRIMARY key.
  The engine is InnoDb.</p>
  
  <p>Rows are created with Doctrine using <a href="https://github.com/ramsey/uuid-doctrine#innodb-optimised-binary-uuids" rel="nofollow noreferrer">https://github.com/ramsey/uuid-doctrine#innodb-optimised-binary-uuids</a> as per <a href="https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/" rel="nofollow noreferrer">https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/</a></p>
  
  <p>For instance the uuid <code>55a54172-f5e4-11e8-aa0d-fe02fd3f406</code> is stored as <code>HEX(id) = 11E8F5E455A54172AA0DFE02FD3F406</code> in the database</p>
  
  <p>I'm trying to search for rows with the same string beginning.</p>
  
  <p>Something like this with pseudo code</p>
  
  <pre><code>SELECT *
  FROM log
  WHERE id LIKE 11E8F5E4
  </code></pre>
  
  <p>I've tried to query</p>
  
  <pre><code>SELECT HEX(`id`) AS `id`
  FROM `log`
  WHERE (`id` &amp; UNHEX('11E8F5E4')) = UNHEX('11E8F5E4')
  LIMIT 10
  </code></pre>
  
  <p>which is fast but rows with a different prefix like <code>11E8E8AD47E47970B1C9525400B61105</code> are returned</p>
  
  <p><strong>How may I do it while using the Btree index (for perf reason)?</strong></p>