Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.