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
idorname) before inserting. - Use
INSERT IGNOREorREPLACE INTOif overwriting is acceptable. - Otherwise, remove or rename the conflicting entry.
ℹ️ Additional Information
- Always ensure your
idcolumn usesAUTO_INCREMENT. - For items, confirm no duplicate
nameexists in theitemstable.
Error Code: 1062. Duplicate entry 'X' for key 'PRIMARY'`