Duplicates removal after inserting

Hi Guys,

I have a CSV file that will insert mobile numbers in to a database and use the following to build the table

CREATE TABLE IF NOT EXISTS `".$tablename."` (
  `number` varchar(11) NOT NULL,
  `message` varchar(160) DEFAULT NULL,
  `sent` varchar(1) NOT NULL DEFAULT '0',
  `date` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

once the data has been inserted what command should i run to ensure that anything in the numbers in unique and remove any duplicates.

I wish for this to be done once the data has been inserted so that if a user submit’s a CSV with duplicate numbers they do not have to remove them or get an error.

fixed via


CREATE TABLE IF NOT EXISTS `".$tablename."` (
  `number` varchar(11) NOT NULL,
  `message` varchar(160) DEFAULT NULL,
  `sent` varchar(1) NOT NULL DEFAULT '0',
  `date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`number`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

and doing the following to ignore duplicates in the numbers field.


$db->prepare('
            INSERT IGNORE INTO `'.$tablename.'` (                                      
                `number`
            ) VALUES ( 
                ?           
            )
        ');