join - Select rows with most frequent values of one column MySQL -


this question has answer here:

i'd select rows table contain 50 frequent values of column. tried use such join, seems choice of left join wrong. inner part of statement seems fine. should change in statement?

select col1, col2  tbl t1  left join (     select id      tbl      id > 123        , id < 987654      group col1      order count(id) desc      limit 50 ) t2  on t1.id = t2.id 

rather join, have tried using in operator part of clause?

for example...

select col1, col2  tbl t1  t1.id in (     select id      tbl      id > 123          , id < 987654      group col1      order count(id) desc      limit 50 ) 

Comments