Bug #99142 The result mismatches when DISTINCT syntax exists
Description:
When the DISTINCT syntax is added to the SQL, the result mismatches.
How to repeat:
CREATE TABLE t1 (
a INT,
b INT);
INSERT INTO t1 VALUES(1, 2), (3, 4);
root@localhost:test 8.0.16-rds-dev> SELECT if(COALESCE(aa.a, 'hope') = 'hope', 'hope', group_concat(distinct concat(aa.a, ""))) FROM t1 aa LEFT JOIN t1 bb ON aa.a = bb.a GROUP BY bb.b, aa.a;
+--------------------------------------------------------------------------------------+
| if(COALESCE(aa.a, 'hope') = 'hope', 'hope', group_concat(distinct concat(aa.a, ""))) |
+--------------------------------------------------------------------------------------+
| 1 |
| 3 |
+--------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
root@localhost:test 8.0.16-rds-dev> SELECT DISTINCT if(COALESCE(aa.a, 'hope') = 'hope', 'hope', group_concat(distinct concat(aa.a, ""))) FROM t1 aa LEFT JOIN t1 bb ON aa.a = bb.a GROUP BY bb.b, aa.a;
+--------------------------------------------------------------------------------------+
| if(COALESCE(aa.a, 'hope') = 'hope', 'hope', group_concat(distinct concat(aa.a, ""))) |
+--------------------------------------------------------------------------------------+
| 1 |
+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
The above results of the two queries are obviously inconsistent.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.