title: How to insert values into one column based on values of another column for each row?
body: <pre class="lang-sql prettyprint-override"><code># table schema
  CREATE TABLE `ref_str` (
    `ref_id` int(11) DEFAULT NULL,
    `ref_str` varchar(4096) DEFAULT NULL,
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
  </code></pre>
  <p>This is current data:</p>
  <pre><code>+--------+--------------------+
  | ref_id | ref_str            |
  +--------+--------------------+
  |   NULL | [5] www.NCCN.com   |
  |   NULL | [4] www.nhc.gov.cn |
  |   NULL | [14] www.hc.gov.cn |
  |   NULL | [146] someh.gov.cn |
  +--------+--------------------+
  </code></pre>
  <p>And I want to iteratively insert into <code>ref_id</code> column the int value inside <code>[]</code> of <code>ref_str</code> of same row.</p>
  <p>The result should look like:</p>
  <pre><code>+--------+--------------------+
  | ref_id | ref_str            |
  +--------+--------------------+
  |    5   | [5] www.NCCN.com   |
  |    4   | [4] www.nhc.gov.cn |
  |   14   | [14] www.hc.gov.cn |
  |  146   | [146] someh.gov.cn |
  +--------+--------------------+
  </code></pre>
  <p>I'm using MySQL 5.7.32.</p>
  <p>Thanks.</p>