Details
Description
Subquery in result column complains about returning multiple rows even though an aggregation is done over the rows.
CREATE TABLE t1 ( a INT(11) ); INSERT INTO t1 (a) VALUES (1), (2); CREATE TABLE t2 ( b INT(11) ); INSERT INTO t2 (b) VALUES (1), (2); SELECT a, ( SELECT SUM(a + c) FROM ( SELECT b as c FROM t2 ) AS v1 ) FROM t1;
Result:
ERROR 1242 (21000): Subquery returns more than 1 row
Expected
a subquery 1 5 2 7
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Thank you.
As a workaround, you can temporarily set derived_merge=off in your optimizer_switch:
optimizer_switch=derived_merge=off'
^ in the config file for future server starts
and/or
SET GLOBAL optimizer_switch = 'derived_merge=off';
SET optimizer_switch = 'derived_merge=off';
^ from the client for the currently running server.