Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Query that is being ran:

INSERT INTO `log_url` (`url_id`, `visitor_id`, `visit_time`) VALUES (?, ?, ?)

Error that is being thrown:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '41721' for key 1

Where does 41721 fall into? How do I read this? How do I check the 'key 1'?

share|improve this question
up vote 3 down vote accepted

Run this command : SHOW CREATE TABLE log_url\G

This will give you a display of the SQL needed to create the table.

It will also show you the indexes and constraints for that table.

The first index (key 1) in that table must have a column called url_id.

From the error message, you are being told that there exists a row in log_url that has 41721 already present. You can verify this with SELECT * FROM log_url WHERE url_id = 41721;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.