Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql SQLSTATE[23000]:完整性约束冲突:1062项“group\u key”的重复项“xxx”_Mysql - Fatal编程技术网

Mysql SQLSTATE[23000]:完整性约束冲突:1062项“group\u key”的重复项“xxx”

Mysql SQLSTATE[23000]:完整性约束冲突:1062项“group\u key”的重复项“xxx”,mysql,Mysql,在我的网页上没有插入或更新,但已对此进行了插入或更新,我收到以下错误: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-Bekoo-2449.10' for key 'group_key' 这是令人惊讶的,因为网页不修改任何行,并且产品表没有组键列或键 我的问题是: SELECT Product._like, comment_count, title, p

在我的网页上没有插入或更新,但已对此进行了插入或更新,我收到以下错误:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-Bekoo-2449.10' for key 'group_key'
这是令人惊讶的,因为网页不修改任何行,并且产品表没有组键列或键

我的问题是:

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
和我的表格结构:

` 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`
为什么会出现此错误?

除非您另有说明,否则group_key是MySQL在聚合内容时使用的一个内部字段,因此您不会在自己的表或视图中找到它。其中的重复条目错误意味着您的聚合出现了某种问题


查看正在使用的任何GROUP BY语句,确保其语法正确,尤其是在任何聚合函数和组表达式中。

在Phpmyadmin中,必须截断所有日志表。 这应该可以解决问题

我遇到了同样的问题,我忘记了清除访问者和在线日志。 这两个表都将为用户生成一个日志/id,而XXX for就位于此位置
如果您截断这两个表,它将解决此问题。

我添加了一个编辑。没有包含3个唯一字段的组\主键或唯一索引。某个地方一定有写操作。可能是触发器?在我的表上只有一个键和它的主ID。不,没有写操作,也没有触发器只是post:您的表结构完整显示创建表和查询是否使用DISTINCT、MAX或AVG等聚合函数?不,请看我的查询。选择产品。如,评论数量,标题,价格更低,价格,图片,附属报价。名称,付款,付款,付款方式,付款类型,xml id,品牌,型号,货币,url,产品。aff id,产品。报价id,pb共享1,pb共享2,pb共享1支付日,pb共享2支付日,附属报价。seo标题,afo报价id,r类别,Product.aff_id=AffiliateOffers.aff_id和Product.offer_id=AffiliateOffers.af_offer_id上的产品内部连接AffiliateOffers的seo_描述,其中Product.status=1和Product.aff_id='1'以及Product.offer_id='1290'offer_id和aff_id是INT类型,因此,您不应该将它们与字符串进行比较,因为您使用的是='1290'和='1',我这样做了,但我认为这与错误无关?但感谢阿加尼发现了问题,这是关于不同的。我想通过group by或区分品牌、价格和r_类别,但我无法通过group by实现,因为它太慢了。查询:从Product.status=1、Product.aff\u id=1、Product.offer\u id=1290的产品中,选择不同的r\u类别作为r\u类别,品牌作为品牌,价格作为价格