title: Update column of database table with numeric value column of the same table in MySql
body: <p>The MySQL version is</p>
  <pre><code>mysql&gt; 
  SELECT VERSION();
  +-----------+
  | VERSION() |
  +-----------+
  | 8.0.17    |
  +-----------+
  1 row in set
  </code></pre>
  <p>With <em>LOAD DATA</em> syntax inserting into table <code>text_table</code> a csv file compiled by an external company</p>
  <p>This is the <code>text_table</code></p>
  <p><strong>Image 1</strong></p>
  <p><a href="https://i.stack.imgur.com/imVxr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/imVxr.png" alt="enter image description here" /></a></p>
  <p>After <em>LOAD DATA</em> I need update the column <code>sID_Branch</code> with number value contains of columns <code>sBranch</code>, in this mode</p>
  <p>All the next rows before the next <code>sBranch</code> should also be updated with that same id</p>
  <p><strong>Image 2</strong></p>
  <p><a href="https://i.stack.imgur.com/HQu51.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HQu51.png" alt="enter image description here" /></a></p>
  <p>It's not possible to know in advance how many branches or rows number the csv file are contains, but at this moment there is no alternative to populate the table <code>text_table</code></p>
  <p>Any suggestion please?</p>
  <p>Thanks in advance for any help</p>
  <p>My table below</p>
  <pre><code>DROP TABLE IF EXISTS `text_table`;
  CREATE TABLE `text_table` (
    `sBranch` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
    `sID_Branch` int(11) DEFAULT NULL,
    `sID` int(11) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (`sID`)
  ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
  
  -- ----------------------------
  -- Records of text_table
  -- ----------------------------
  INSERT INTO `text_table` VALUES ('Branch 1', '1', '1');
  INSERT INTO `text_table` VALUES ('- London', '1', '2');
  INSERT INTO `text_table` VALUES ('Pepsi', '1', '3');
  INSERT INTO `text_table` VALUES ('Coca Cola', '1', '4');
  INSERT INTO `text_table` VALUES ('Dr Pepper', '1', '5');
  INSERT INTO `text_table` VALUES ('- Springfield', '1', '6');
  INSERT INTO `text_table` VALUES ('Fanta', '1', '7');
  INSERT INTO `text_table` VALUES ('Duff', '1', '8');
  INSERT INTO `text_table` VALUES ('Branch 2', '2', '9');
  INSERT INTO `text_table` VALUES ('- Manchester', '2', '10');
  INSERT INTO `text_table` VALUES ('Heineken', '2', '11');
  INSERT INTO `text_table` VALUES ('Dreher', '2', '12');
  INSERT INTO `text_table` VALUES ('Ceres', '2', '13');
  INSERT INTO `text_table` VALUES ('- Mexico DF', '2', '14');
  INSERT INTO `text_table` VALUES ('Corona', '2', '15');
  </code></pre>
  <p><strong>Edit #1</strong></p>
  <pre><code>+---------------+------------+-----+
  | sBranch       | sID_Branch | sID |
  +---------------+------------+-----+
  | Branch 1      | NULL       |   1 |
  | - London      | NULL       |   2 |
  | Pepsi         | NULL       |   3 |
  | Coca Cola     | NULL       |   4 |
  | Dr Pepper     | NULL       |   5 |
  | - Springfield | NULL       |   6 |
  | Fanta         | NULL       |   7 |
  | Duff          | NULL       |   8 |
  | Branch 2      | NULL       |   9 |
  | - Manchester  | NULL       |  10 |
  | Heineken      | NULL       |  11 |
  | Dreher        | NULL       |  12 |
  | Ceres         | NULL       |  13 |
  | - Mexico DF   | NULL       |  14 |
  | Corona        | NULL       |  15 |
  +---------------+------------+-----+
  15 rows in set
  </code></pre>
  <p><strong>Update table</strong></p>
  <pre><code>+---------------+------------+-----+
  | sBranch       | sID_Branch | sID |
  +---------------+------------+-----+
  | Branch 1      |          1 |   1 |
  | - London      |          1 |   2 |
  | Pepsi         |          1 |   3 |
  | Coca Cola     |          1 |   4 |
  | Dr Pepper     |          1 |   5 |
  | - Springfield |          1 |   6 |
  | Fanta         |          1 |   7 |
  | Duff          |          1 |   8 |
  | Branch 2      |          2 |   9 |
  | - Manchester  |          2 |  10 |
  | Heineken      |          2 |  11 |
  | Dreher        |          2 |  12 |
  | Ceres         |          2 |  13 |
  | - Mexico DF   |          2 |  14 |
  | Corona        |          2 |  15 |
  +---------------+------------+-----+
  15 rows in set
  </code></pre>