Duplicate entry error
❌ Error
Error Code: 1062. Duplicate entry 'X' for key 'PRIMARY'
📍 Context
Occurs when an INSERT
query tries to insert a row with the same primary key or unique index as an existing row.
This is common in FiveM when inserting items, vehicles, or upgrades with duplicate IDs/names.
✅ Solution
- Check the primary key (usually
id
orname
) before inserting. - Use
INSERT IGNORE
orREPLACE INTO
if overwriting is acceptable. - Otherwise, remove or rename the conflicting entry.
ℹ️ Additional Information
- Always ensure your
id
column usesAUTO_INCREMENT
. - For items, confirm no duplicate
name
exists in theitems
table.
Error Code: 1062. Duplicate entry 'X' for key 'PRIMARY'`