user8607392
user8607392

Reputation:

mysql sql_mode=only_full_group_by in subquery not working

I've tried a lot of ways, mentioned here and other forums, but still get stucked in it:

when I'm running the query

select a, group_concat(b) from table1 group by a

working perfectly.

Wneh I put it in a subquery, ex.

select table2.c, t1.conc  
from table2 
inner join (
   select a, group_concat(b) as conc 
   from table1 group by a) as t1 
on t1.a = tabke2.d`

I get this:

expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column .... is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

But why?? If it works stand alone!?

Upvotes: 0

Views: 253

Answers (1)

P.Salmon
P.Salmon

Reputation: 17590

select b.hu as c, count(*) as kdb 
    from d 
    inner join b on b.id = d.alc 
    group by b.c

There isn't as far as I can tell b.c to group by - it looks like you are trying to group on an alias when you should be grouping by b.hu

and in this

select id, c, GROUP_CONCAT(hu) as mk 
    from b 
    group by c, id, hu

you are group_concatenating hu so it makes no sense to group by hu

In fact this query makes very little sense, if I was you I would start over and publish sample data and expected output as text in the question.

Upvotes: 1

Related Questions