Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql解析错误,出现列名重复错误,Duplicate column name ‘xxxx’ #706

Open
foryout opened this issue May 25, 2022 · 4 comments

Comments

@foryout
Copy link

foryout commented May 25, 2022

建表语句中列名存在大写的字段,进行关联查询时,出现此错误,在sql的解析结果中同时出现了,字段的大写名和小写名
explain结果
each(targetName = c0,
................................
right join (
select

.............................

	`t17`.`audit_time`,
	`t17`.`SYSCREATORUUID`,

.......................
t17.syscreatoruuid,
.............

@junwen12221
Copy link
Collaborator

请问这个错,会导致无法返回结果集吗?

要调查这个问题的话,需要涉及的表的建表语句和完整的查询sql

@foryout
Copy link
Author

foryout commented May 25, 2022

无法返回结果集。
建表语句:
CREATE TABLE IF NOT EXISTS tb01 (
oo_uuid char(32) NOT NULL,
ss_type varchar(5) NOT NULL,
my_uuid char(32) NOT NULL,
cc_uuid char(32) NOT NULL,
SYSUUID char(32) NOT NULL,
PRIMARY KEY USING BTREE (oo_uuid),
KEY sharding_uuid USING BTREE (my_uuid)
) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_bin
DBPARTITION BY hash(my_uuid);

CREATE TABLE IF NOT EXISTS tb02 (
cc_uuid char(32) NOT NULL,
my_uuid CHAR(32) NOT NULL,
sysuuid CHAR(32) NOT NULL,
aaaa varchar(20) NOT NULL,
bbbb char(32) NOT NULL,
cccc varchar(20) DEFAULT NULL,
PRIMARY KEY USING BTREE (cc_uuid),
KEY sharding_uuid USING BTREE (my_uuid)
) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_bin
DBPARTITION BY hash(my_uuid);

CREATE TABLE IF NOT EXISTS tb03 (
id bigint(20) NOT NULL AUTO_INCREMENT,
ss_type varchar(50) NOT NULL,
ss_code varchar(5) NOT NULL,
PRIMARY KEY USING BTREE (id),
UNIQUE KEY uni_idx USING BTREE (ss_type, ss_code)
) BROADCAST ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_bin;

查询sql:
SELECT
COUNT(*) TOTAL_NUM
FROM
( SELECT
A.OO_UUID
FROM
tb01 A
LEFT JOIN tb02 B
ON B.my_uuid = A.my_uuid AND
B.cc_uuid = A.cc_uuid
LEFT JOIN tb03 C
ON C.ss_code = A.SS_TYPE
) ALLVIEW;

junwen12221 added a commit that referenced this issue May 26, 2022
@junwen12221
Copy link
Collaborator

junwen12221 added a commit that referenced this issue May 26, 2022
@junwen12221
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants