How can i fix 'duplicate entry for key primary' in sql?
Example:
INSERT INTO users (id, name) VALUES (1, 'John');
INSERT INTO users (id, name) VALUES (1, 'Doe');
This error occurs when trying to insert a row with a primary key that already exists in the table.
Solution:Use a unique value for the primary key or consider using AUTO_INCREMENT for automatic key generation.
INSERT INTO users (id, name) VALUES (2, 'Doe');