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

GROUP_CONCAT error. subquery returns more than 1 row #10608

Closed
799983050 opened this issue May 27, 2019 · 2 comments · Fixed by #10615
Closed

GROUP_CONCAT error. subquery returns more than 1 row #10608

799983050 opened this issue May 27, 2019 · 2 comments · Fixed by #10615
Labels
type/bug This issue is a bug.

Comments

@799983050
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

SELECT ( SELECT GROUP_CONCAT( CONCAT( 123, '-' ) ) FROM user_info ui WHERE ui.id = read_cust_user_id GROUP BY ui.id ) AS levelCode FROM ods_order_item_base_two
Error information is :

1105 - subquery returns more than 1 row
Remarks:
read_cust_user_id is ods_order_item_base_two table field。

  1. What did you expect to see?

Give an explanation.

  1. What did you see instead?
    GROUP BY ui.id
    Change to
    GROUP BY read_cust_user_id
    Successful implementation
  2. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
    Release Version: v2.1.1
    Git Commit Hash: 990f859
    Git Branch: release-2.1
    UTC Build Time: 2018-12-12 10:57:44
    GoVersion: go version go1.11.2 linux/amd64
    Race Enabled: false
    TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
    Check Table Before Drop: false
@XuHuaiyu
Copy link
Contributor

Hi, @799983050 Thanks for your feedback.
The case you mentioned is weird.
I tried to build a simple case to reproduce it but failed.
May you provide us the table schema and data which can reproduce this problem?

tidb> select * from t;
+------+
| a    |
+------+
|    1 |
|    1 |
|    2 |
|    2 |
+------+
4 rows in set (0.00 sec)

tidb> select * from s;
+------+
| a    |
+------+
|    2 |
|    2 |
|    1 |
|    1 |
+------+
4 rows in set (0.00 sec)

tidb>  SELECT ( SELECT GROUP_CONCAT( CONCAT( 123, '-' ) ) FROM t WHERE t.a = s.a GROUP BY t.a ) AS t FROM s;
+-----------+
| t         |
+-----------+
| 123-,123- |
| 123-,123- |
| 123-,123- |
| 123-,123- |
+-----------+
4 rows in set (0.00 sec)

@799983050
Copy link
Author

@XuHuaiyu Hello, I created a model for you to find problems.
`
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS t;
CREATE TABLE t (
id int(11) NOT NULL,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

INSERT INTO t VALUES (508931);
INSERT INTO t VALUES (508932);

SET FOREIGN_KEY_CHECKS = 1;

`

`
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS s;
CREATE TABLE s (
id int(11) NOT NULL,
read_cust_user_id int(11) NOT NULL,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

INSERT INTO s VALUES (100292, 508931);
INSERT INTO s VALUES (120002, 508932);

SET FOREIGN_KEY_CHECKS = 1;`

图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants