OiO.lk Blog SQL Duplicate Entry Key error when initial 6 characters match
SQL

Duplicate Entry Key error when initial 6 characters match


I have a table BLE_PINS with columns TN, MAC, PIN, and Date. MAC is the primary key. When entering

INSERT INTO `BLE_PINS` (`MAC`, `PIN`) VALUES ('SEEP413E68','99933');

I get the error

#1062 – Duplicate entry ‘SEEP41’ for key ‘PRIMARY’`.

It seems to be matching only the first 6 characters. Is there a way to change that?

Table definition:

CREATE TABLE BLE_PINS ( 
    TN varchar(16) DEFAULT NULL, 
    MAC varchar(100) NOT NULL, 
    PIN varchar(6) NOT NULL, 
    Date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    PRIMARY KEY (MAC(6)) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1



You need to sign in to view this answers

Exit mobile version