Why am i seeing 'duplicate entry' error in sql?

This error pops up when you try to insert a record that would cause a duplicate entry in a unique column. Example:

INSERT INTO users (username) VALUES ('JohnDoe');
INSERT INTO users (username) VALUES ('JohnDoe'); -- Will cause an error
Solution:

-- Ensure unique values are provided for unique columns
INSERT INTO users (username) VALUES ('JohnDoe2');
Check the unique constraints and ensure you're not violating them.

Beginner's Guide to SQL