title: Mysql update a row if its the only matching result
body: <p>I have a table like so:</p>
  
  <pre><code>Item
  ---------
  id
  parentId
  name
  inventoryNumber
  </code></pre>
  
  <p>I need to update the inventoryNumber if and only if the row...</p>
  
  <ol>
  <li>parentId = 12345 </li>
  <li>name string matches exactly a given string "The
  quick brown fox" </li>
  <li>the row is the only row that matches the first two
  criteria.</li>
  </ol>
  
  <p>I believe I know how to do this if I was just doing a select...</p>
  
  <pre><code>SELECT * FROM Item WHERE parentId=12345 
  AND name LIKE 'The quick brown fox' HAVING count(*)=1
  </code></pre>
  
  <p>but I need to update the row...</p>
  
  <p><code>UPDATE Item SET inventoryNumber = 456 WHERE</code> <em>this is the only row where parentId=12345 and the only row where name='The quick brown fox'</em></p>
  
  <p>I have about 5000 of these rows to update so it would greatly reduce my workload if I can get a way to update in a single statement.  Can this be done?</p>
  
  <p><strong>UPDATE:</strong> I already tried putting this in a subquery like:</p>
  
  <pre><code>UPDATE Item SET inventoryNumber = 456 WHERE id IN (
     SELECT id 
     FROM Item 
     WHERE parentId = 12345 AND name LIKE 'The quick brown fox' HAVING count(*)=1
  );
  </code></pre>
  
  <p>But I get an error from MySql when I do that "You can't specify target table 'item' for update in FROM clause:</p>