# Initialise --disable_warnings drop table if exists t1,t2; --enable_warnings create table t1 (a1 int, b1 int, c1 int); create table t2 (a2 int, b2 int, c2 int); insert into t1 values (1,11,111), (2,22,222), (2,22,222), (3,33,300), (3,33,301), (4,44,444); insert into t2 values (1,11,111), (2,22,222), (2,22,222), (3,33,300), (3,33,301), (5,55,555); SET @@sql_mode='ansi'; explain extended select a1, (select count(b1) from t2 limit 1) from t1 group by a1; explain extended select a1 from t1 group by a1 having (select count(b1) from t2 limit 1) ; explain extended select a1, (select 1 from t2 where count(b1) limit 1) from t1 group by a1; explain extended select a1 from t1 group by a1 having (select 1 from t2 where count(b1) limit 1) ; explain extended select (select group_concat(sum(b1)) from t2 limit 1) from t1; SET @@sql_mode=default; explain extended select a1, (select count(b1) from t2 limit 1) from t1 group by a1; explain extended select a1 from t1 where (select count(b1) from t2 limit 1) ; # NOT OUTER explain extended select a1 from t1 group by a1 having (select count(b1) from t2 limit 1) ; explain extended select a1, (select 1 from t2 where count(b1) limit 1) from t1 group by a1; explain extended select a1 from t1 group by a1 having (select 1 from t2 where count(b1) limit 1) ; explain extended select (select group_concat(sum(b1)) from t2 limit 1) from t1; explain extended select a1, (select 1 from t2 where count(*) limit 1) from t1 group by a1; explain extended select a1 from t1 group by a1 having (select 1 from t2 where count(*) limit 1) ;