Skip to main content

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 or name) before inserting.
  • Use INSERT IGNORE or REPLACE INTO if overwriting is acceptable.
  • Otherwise, remove or rename the conflicting entry.

ℹ️ Additional Information

  • Always ensure your id column uses AUTO_INCREMENT.
  • For items, confirm no duplicate name exists in the items table.
    Error Code: 1062. Duplicate entry 'X' for key 'PRIMARY'`