I'd like to select all rows from a table which contain 50 most frequent values of the column. I tried to use such a join, but it seems my choice of LEFT JOIN is wrong. The inner part of the statement seems fine. What should I change in my statement?
SELECT col1, col2 
FROM tbl as t1 
LEFT JOIN (
    SELECT id 
    FROM tbl 
    WHERE id > 123 
      AND id < 987654 
    GROUP BY col1 
    ORDER BY COUNT(id) DESC 
    LIMIT 50
) AS t2 
ON t1.id = t2.id
 
     
     
    