title: Incorrect DECIMAL value when inserting MySQL
body: <p>The error I'm getting is:</p>
  
  <blockquote>
    <p>ERROR 1366 (HY000): Incorrect DECIMAL value: '0' for column '' at row
    -1</p>
  </blockquote>
  
  <p>I'm trying to <code>normalize</code> a database and ensuring that the data types are correct. Inserting data from <code>BASE_TABLE</code> into a new table named <code>Inventors</code>.</p>
  
  <p>This is the query I'm using to insert. If I take a single row <strong>manually</strong> from the <code>select</code> query it can correctly insert into the Inventors table.</p>
  
  <p>However, running the query like this I instantly get the error above.</p>
  
  <pre><code>INSERT INTO
      Inventors(ID,Firstname,Middlename,Lastname,Country,Latitude,Longitude)
  SELECT DISTINCT
      Inventor_ID as ID,
      Firstname,
      Middlename,
      Lastname,
      Country,
      cast(Latitude as decimal(11,6)) as Latitude,
      cast(Longitude as decimal(11,6)) as Longitude
  FROM
      BASE_TABLE
  </code></pre>
  
  <p>Here is the row which fails to insert in the <code>select</code> query:</p>
  
  <pre><code>ID          Firstname   Middlename  Lastname    Country     Latitude    Longitude
  04308666-3  RICHARD     RICHARD     JUNG                    0.000000    0.000000
  </code></pre>
  
  <p><code>Inventors</code> create query:</p>
  
  <pre><code>CREATE TABLE `Inventors` (
    `ID` varchar(55) NOT NULL DEFAULT '',
    `Firstname` varchar(255) DEFAULT NULL,
    `Middlename` varchar(255) DEFAULT NULL,
    `Lastname` varchar(255) DEFAULT NULL,
    `Country` varchar(255) DEFAULT NULL,
    `Latitude` decimal(11,8) DEFAULT NULL,
    `Longitude` decimal(11,8) DEFAULT NULL,
    PRIMARY KEY (`ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p><code>BASE_TABLE</code> create query:</p>
  
  <pre><code>CREATE TABLE `BASE_TABLE` (
    `Firstname` varchar(255) DEFAULT NULL,
    `Middlename` varchar(255) DEFAULT NULL,
    `Lastname` varchar(255) DEFAULT NULL,
    `Country` varchar(255) DEFAULT NULL,
    `Zipcode` varchar(255) DEFAULT NULL,
    `Latitude` varchar(255) DEFAULT NULL,
    `Longitude` varchar(255) DEFAULT NULL,
    `InvSeq` int(11) DEFAULT NULL,
    `Patent` varchar(255) DEFAULT NULL,
    `AppYear` year(4) DEFAULT NULL,
    `ApplyYear` year(4) DEFAULT NULL,
    `PubYear` year(4) NOT NULL,
    `AppDate` varchar(255) DEFAULT NULL,
    `Assignee` varchar(255) DEFAULT NULL,
    `AsgNum` varchar(255) DEFAULT NULL,
    `Class` varchar(255) DEFAULT NULL,
    `Coauthor` varchar(255) DEFAULT NULL,
    `Invnum` varchar(255) DEFAULT NULL,
    `Invnum_N` varchar(255) DEFAULT NULL,
    `Record_ID` varchar(255) NOT NULL,
    `Inventor_ID` varchar(255) DEFAULT NULL,
    `Match_Level` tinyint(4) DEFAULT NULL,
    `Company_ID` varchar(255) DEFAULT NULL,
    `Classification` varchar(255) DEFAULT NULL,
    `Citing` mediumint(9) DEFAULT NULL,
    `Cited` mediumint(9) DEFAULT NULL,
    PRIMARY KEY (`Record_ID`),
    KEY `Inventor_ID` (`Inventor_ID`),
    KEY `Patent` (`Patent`),
    KEY `Patent_2` (`Patent`,`Inventor_ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>Can anyone help me on this issue?</p>