Muhammet Arslan
Muhammet Arslan

Reputation: 985

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xxx' for key 'group_key'

On my web page there is no insert or update but already to this I'm getting this error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-Bekoo-2449.10' for key 'group_key'

This is surprising because the web page does not modify any rows, and the Product table does not have a group_key column or key.

My query :

SELECT Product._like,
       comment_count,
       title,
       price_lower,
       price,image,
       AffiliateOffers.name,
       p‌​‌​ayout_yuzde,
       payout_nakit,
       payout_type,
       xml_id,
       brand,model,
       currency,url,
       Product.af‌​f_‌​id,
       Product.offer_id,
       pb_share_1,
       pb_share_2,
       pb_share_1_payda,
       pb_share_2_payda,
       A‌​ffil‌​iateOffers.seo_title,
       afo_offer_id,
       r_category,
       seo_description 
FROM Product 
inner Join AffiliateOffers on Product.aff_id = AffiliateOffers.af_id 
      AND Product.offer_id = AffiliateOffers.af_offer_id 
where Product.status = 1 
    and Product.aff_id = 1 
    and Product.offer_id = 1290

and my table structure :

` CREATE TABLE `_product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `xml_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `aff_id` int(11) NOT NULL,
  `offer_id` int(11) NOT NULL,
  `r_category` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `category_id1` int(11) NOT NULL,
  `category_id2` int(11) NOT NULL,
  `category_id3` int(11) NOT NULL,
  `brand` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `model` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL,
  `title` mediumtext COLLATE utf8_unicode_ci NOT NULL,
  `description_1` mediumtext COLLATE utf8_unicode_ci,
  `price` decimal(18,2) NOT NULL,
  `price_lower` decimal(18,2) NOT NULL,
  `percentage_lower` int(11) NOT NULL,
  `image` mediumtext COLLATE utf8_unicode_ci NOT NULL,
  `url` text COLLATE utf8_unicode_ci,
  `feature` tinyint(4) NOT NULL,
  `city` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `sex` tinyint(4) NOT NULL,
  `stock` tinyint(4) NOT NULL,
  `start_date` int(25) NOT NULL,
  `finish_date` int(25) NOT NULL,
  `update_date` int(25) NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `hit` int(11) NOT NULL DEFAULT '1',
  `_like` int(11) NOT NULL DEFAULT '0',
  `comment_count` int(11) DEFAULT NULL,
  `like_count` int(11) DEFAULT NULL,
  `lastlike_time` int(25) DEFAULT NULL,
  `visit_count` int(11) DEFAULT NULL,
  `lastvisit_count` int(25) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `xml_id` (`xml_id`),
  KEY `lastlike_time` (`lastlike_time`),
  KEY `offer_id` (`offer_id`),
  KEY `r_category` (`r_category`),
  KEY `status` (`status`)
) ENGINE=MyISAM AUTO_INCREMENT=3816867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci`

Why am I getting this error?

Upvotes: 0

Views: 3005

Answers (2)

user1629905
user1629905

Reputation: 71

In Phpmyadmin you have to truncate all the logtables. That should fix it.

I ran into the same problem, i was forgotten to clear the visitor and online log. Both of the tables are generate a log/id for the user ( thats where the XXX for stands ) If you truncate both of the tables it will fix this problem.

Upvotes: 0

Jeremy Smyth
Jeremy Smyth

Reputation: 23503

Unless you say otherwise, group_key is an internal field used by MySQL when aggregating things so you won't find it in your own tables or view. A duplicate entry error in there means you've got some sort of problem with your aggregation.

Have a look at any GROUP BY statements you're using, and ensure you've got their syntax correct, particularly in any aggregate functions and group expressions.

Upvotes: 2

Related Questions