title: Use ON DUPLICATE KEY UPDATE for some part of unique mapping key
body: <p>I have table as shown below</p>
  
  <pre><code>   ItemAttMapID    ItemAttributeID    VendorID    vItemID    Qty
          1                4               1           2       60
          2                4               2           3       10
          3                3               5           5       20
  </code></pre>
  
  <p>In this table <code>ItemAttMapID</code> is <code>auto_increment</code> <code>primary_key</code></p>
  
  <p>and <code>ItemAttributeID, VendorID, VItemID</code> is <code>Unique Mapping</code>.</p>
  
  <p>I used following query</p>
  
  <pre><code>INSERT INTO `client`.`mapping`  
  (`ItemAttMapID`, `ItemAttributeID`, `VendorID`, `vItemID`, `Qty`)  
  
  VALUES  
  (NULL, 4, '2', '3', '70'),  
  (NULL, 3, '5', '5', '80')  
  ON DUPLICATE KEY UPDATE Qty = VALUES(Qty);
  </code></pre>
  
  <p>It gives me proper result which I want
  but when I used following query instead of updating the perticular record it inserts the new one.</p>
  
  <pre><code>INSERT INTO `client`.`mapping`  
  (`ItemAttMapID`, `ItemAttributeID`, `VendorID`, `vItemID`, `Qty`)  
  
  VALUES  
  (NULL, 2, '5', '5', '80')  
  ON DUPLICATE KEY UPDATE Qty = VALUES(Qty);
  </code></pre>
  
  <p>and change in table is like this</p>
  
  <pre><code>   ItemAttMapID    ItemAttributeID    VendorID    vItemID    Qty
          1                4               1           2       60
          2                4               2           3       10
          3                3               5           5       20
          4                2               5           5       80  
  </code></pre>
  
  <p>I want the 3rd number row to update but It is inserting a new record to table.</p>
  
  <p>How can I achieve this using ON DUPLICATE KEY UPDATE.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I want to check only, if <code>VendorID</code> and <code>vItemID</code> is already present then update the record ( NOT THE <code>ItemAttributeID</code>) using ON DUPLICATE KEY UPDATE..</p>
  
  <p>Because if I put <code>ItemAttributeID</code> same along with <code>VendorID</code> and <code>vItemID</code> in query then it updates the record otherwise its inserting new record.</p>