title: MYSQL - Problems using a string as primary key
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2969874/alphanumeric-order-by-in-mysql">Alphanumeric Order By in Mysql</a>  </p>
  </blockquote>
  
  
  
  <p>My tables are sorting my records incorrectly. The primary key is a string that as one char and its combined with a number starting from 1 ex: F1. It becomes problematic when it got to two digit numbers ex: F10. The database only check the first two characters  and discard the rest. Ex:</p>
  
  <p>It should look like this F1,F2,F3,...F9,F10,F11,etc.</p>
  
  <p>It looks like this F1, F10, F11, F12,....,F2,F3,F4,etc.</p>
  
  <p>So if you have any ideas please share it.</p>
  
  <p>Note: using MySql 5 server and MySql Workbench 5.2</p>
  
  <p>Here is the script code for one table in the database:</p>
  
  <pre><code>SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  
  SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  
  SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
  
  
  
  DROP SCHEMA IF EXISTS `RimpexDB` ;
  
  CREATE SCHEMA IF NOT EXISTS `RimpexDB` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci ;
  
  USE `RimpexDB` ;
  
  
  
  -- -----------------------------------------------------
  
  -- Table `RimpexDB`.`RpxFornecedor`
  
  -- -----------------------------------------------------
  
  DROP TABLE IF EXISTS `RimpexDB`.`RpxFornecedor` ;
  
  
  
  CREATE  TABLE IF NOT EXISTS `RimpexDB`.`RpxFornecedor` (
  
    `FID` VARCHAR(80) NOT NULL ,
  
    `FNome` VARCHAR(80) NOT NULL ,
  
    `FDescricao` VARCHAR(1000) NULL ,
  
    `FNTel` VARCHAR(45) NULL ,
  
    `FNCel` VARCHAR(45) NULL ,
  
    `FEndereco` VARCHAR(200) NOT NULL ,
  
    `FEmail` VARCHAR(100) NULL ,
  
    `FFax` VARCHAR(45) NULL ,
  
    `FActivo` CHAR NOT NULL ,
  
    `FDataAct` VARCHAR(200) NOT NULL ,
  
    `FDataNAct` VARCHAR(200) NULL ,
  
    PRIMARY KEY (`FID`) ,
  
    INDEX `FID` (`FID` ASC, `FNome` ASC, `FDescricao` ASC, `FNTel` ASC, `FNCel` ASC, `FEndereco` ASC, `FEmail` ASC, `FFax` ASC, `FActivo` ASC, `FDataAct` ASC, `FDataNAct` ASC) )
  
  ENGINE = InnoDB
  
  COMMENT = 'Fornecedor Table' ;
  
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  </code></pre>