title: MySQL - parse and move data from table 1 to table 2
body: <p>Here's my situation - I have a large text table downloaded from the web and it is a series of 5 variables with fixed widths on each line - "space" delimited.</p>
  
  <p>I'm using phpMYADMIN to upload data (I've been successful with comma-delimited uploads in the past), but this particular table is so "beautiful" and "easy to use" I'd like to upload it and learn about uploading fixed width tables into a db.</p>
  
  <p>On the web I found a suggestion to upload the fixed width table as a series of single rows, then do something with it later.
  That was successful.</p>
  
  <p>So now I have a table named "monolith" with one column and 90,000 rows with each row about 450 characters long.</p>
  
  <p>Also, from the same page, they suggested using simple MySQL code on the "monolith" table, parsing each row, and putting those variables in the target table. I played around with that code and finally decided on this:</p>
  
  <pre><code>INSERT INTO icd10new
      (icd10order, icd10code, icd10header, icd10short, icd10long)
  SELECT SUBSTRING(1,5) AS 'icd10order',
      SUBSTRING(7,7) AS 'icd10code',
      SUBSTRING(15,1) AS 'icd10header',
      SUBSTRING(17, 60) AS 'icd10short',
      SUBSTRING(78, 255) AS 'icd10long'
  FROM monolith;
  </code></pre>
  
  <p>The code "completes", but the table is either completely empty (correct number of total rows) or the third variable is filled with "15".</p>
  
  <p>I've tried the code with and without single quotes, put all the substrings in a VALUE(), and nothing seems to work.</p>
  
  <p>Would someone be kind enough to point out my errors?</p>