title: How to find out if one field in a given table row contains the value of another field in the same table and row in MySQL
body: <p>I have a <code>license</code> table that contains the <code>type</code> of license and the license <code>number</code>. The user was supposed to type in the entire license number (including type and number) as shown on their license. I <em><strong>inherited</strong></em> a database with some who followed the rules and some who did not. See the table below for samples.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>type</th>
  <th>number</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>RN</td>
  <td>2676612</td>
  </tr>
  <tr>
  <td>PN</td>
  <td>1234567</td>
  </tr>
  <tr>
  <td>RN</td>
  <td>RN2676612</td>
  </tr>
  <tr>
  <td>PN</td>
  <td>PN1234567</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Only the third and fourth entries are correct. I am trying to find entries that are like the first two entries and update the number field to contain the type. So, find the first and second rows and update them to the third and fourth rows respectively.</p>
  <p>I tried</p>
  <p>Select *
  from <code>licenses</code>
  WHERE <code>number</code> NOT LIKE <code>type</code>+'%'</p>
  <p>to try and select them before trying an update query, and I get error #1064. I have found several solutions that find if the value in one column is present anywhere in another column, but I need to know if the <code>number</code> field contains the <code>type</code> field from the SAME ROW.</p>