Mycat2 icon indicating copy to clipboard operation
Mycat2 copied to clipboard

使用group_concat 函数,结果返回了两个值,其中第一个为null,而在mysql中只返回一个值

Open ArchangelLiang opened this issue 3 years ago • 5 comments

sql:

SELECT
	group_concat( industry_name) 
FROM
	hunt_industry;

result:

image

ArchangelLiang avatar May 13 '22 07:05 ArchangelLiang

hunt_industry是单表吗

junwen12221 avatar May 13 '22 09:05 junwen12221

如果有主从,检查一下主从的值是否相同

junwen12221 avatar May 13 '22 09:05 junwen12221

可以给一下配置

junwen12221 avatar May 13 '22 09:05 junwen12221

可以给一下配置

	"shardingTables":{
		"hunt_industry":{
			"createTableSQL":"CREATE TABLE IF NOT EXISTS `headhunt`.`hunt_industry` (\n\t`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',\n\t`industry_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '行业名称',\n\t`parent_id` int UNSIGNED NOT NULL DEFAULT '0' COMMENT '父级行业 ID',\n\t`is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除(见字典 v_hunt_is_deleted 表)',\n\t`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',\n\t`update_time` datetime DEFAULT NULL COMMENT '修改时间',\n\t`tenant_id` int NOT NULL COMMENT '租户id',\n\tPRIMARY KEY USING BTREE (`id`),\n\tKEY `idx_hunt_industry_tenant_id` USING BTREE (`tenant_id`)\n) ENGINE = InnoDB AUTO_INCREMENT = 2269 CHARSET = utf8mb3 ROW_FORMAT = DYNAMIC COMMENT '行业表'\nDBPARTITION BY mod_hash(tenant_id) DBPARTITIONS 2",
			"function":{
				"properties":{
					"dbNum":"2",
					"mappingFormat":"c${targetIndex}/headhunt_${dbIndex}/hunt_industry_${tableIndex}",
					"storeNum":1,
					"dbMethod":"mod_hash(tenant_id)"
				}
			},
			"shardingIndexTables":{}
		},

ArchangelLiang avatar May 13 '22 09:05 ArchangelLiang

https://www.yuque.com/ccazhw/ml3nkf/eeb80583661e42bb8ee4d767e319205d

这个函数暂时不支持的,要等下一次大升级才可以支持, 暂时的解决方式看上面的链接

暂时只有一个用法可以获得正确的结果,写上分片条件命中一个分区,就可以获得正确的结果

junwen12221 avatar May 13 '22 13:05 junwen12221