title: Why update fails because of unique index while there isn't duplicate value?
body: <p>I guess this image explains everything:</p>
  
  <p><a href="https://i.stack.imgur.com/VVbrB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VVbrB.png" alt="enter image description here"></a></p>
  
  <p>See? I'm setting the value of <code>2</code>, but it says <code>0</code> is duplicate. Why? Where that <code>0</code> comes from?</p>
  
  <hr>
  
  <p>Here is the table structure:</p>
  
  <pre><code>-- phpMyAdmin SQL Dump
  -- version 4.7.0
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Mar 04, 2018 at 04:18 PM
  -- Server version: 10.1.26-MariaDB
  -- PHP Version: 7.1.8
  SET
     SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET
     AUTOCOMMIT = 0;
  START TRANSACTION;
  SET
     time_zone = " + 00:00";
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
  ;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */
  ;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */
  ;
  /*!40101 SET NAMES utf8mb4 */
  ;
  --
  -- Database: `spy`
  --
  -- --------------------------------------------------------
  --
  -- Table structure for table `support_us`
  --
  CREATE TABLE `support_us` ( `id` int(10) UNSIGNED NOT NULL, `user_id` int(10) UNSIGNED DEFAULT NULL COMMENT 'null means have not logged in', `full_name` varchar(100) CHARACTER 
  SET
     utf8 COLLATE utf8_unicode_ci NOT NULL, `publish_name` tinyint(1) NOT NULL COMMENT '1 means show the name and 0 means don''t', `user_amount` varchar(20) NOT NULL, `final_amount` varchar(20) DEFAULT NULL, `cell_phone` varchar(20) NOT NULL, `trans_id` varchar(20) DEFAULT NULL COMMENT 'null means it''s just a intention (trans_id hasn''t issued yet by pay.ir)', `status_started` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 means the user is getting redirect to bank page and 0 means it couldn''t connect to bank port', `send_error_code` varchar(10) DEFAULT NULL COMMENT 'go to function.php fine, send() function', `status_finished` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 means finished successfully and 0 means failed', `verify_error_code` varchar(10) DEFAULT NULL COMMENT 'go to function.php fine, verify() function', `card_number` varchar(20) DEFAULT NULL, `message` varchar(200) DEFAULT NULL, `date_time` int(10) UNSIGNED NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1;
  --
  -- Indexes for dumped tables
  --
  --
  -- Indexes for table `support_us`
  --
  ALTER TABLE `support_us` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `trans_id` (`trans_id`), ADD KEY `publish_name` (`publish_name`);
  --
  -- AUTO_INCREMENT for dumped tables
  --
  --
  -- AUTO_INCREMENT for table `support_us`
  --
  ALTER TABLE `support_us` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 41;
  COMMIT;
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
  ;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
  ;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */
  ;
  </code></pre>