Q:

MySQL check rows that has all kinds of another row

I want to know if there is a query to get some rows that have all kinds of another row
I have an example table like this
id  Col_1   Col_2
 1.  A       1
 2.  A       2
 3.  A       3
 4.  A       4
 5.  B       1
 6.  B       2
 7.  B       3
 8.  C       1
 9.  C       2
10.  D       3

In this case, Col_2 can only contain 1 - 4
The expected result is the query would produce
id  Col_1   Col_2
 1.  A       1
 2.  A       2
 3.  A       3
 4.  A       4

Because A has all kinds of Col_2

A:

Lets your table name is test.
SELECT 
    t1.id,
    t1.Col_1,
    t1.Col_2
FROM test t1
INNER JOIN (
    SELECT t2.Col_1
    FROM test t2
    WHERE t2.Col_2 IN (2, 3)  -- Add where clause here
    GROUP BY t2.Col_1
    HAVING COUNT(0) = 2 -- change count based on where, you can also use COUNT(DISTINCT Col_2)
) AS temp ON t1.Col_1 = temp.Col_1
WHERE t1.Col_2 IN (2,3);  -- Add here too, to make sure you only get 2 records for A and B.

