I hope I worded the title correctly, I'm drawing a blank right now on the correct terms so I'll describe what I'm trying to do instead.
I want to return only the rows in a table that all have the same value in one column but only if they all have a specific value in another column.
So here's an example of the 2 columns in the table:
Number | Letter
1 | a
1 | a
2 | a
2 | b
3 | c
3 | b
4 | c
4 | c
5 | c
So I want to return all of the Numbers that have only C for all of their Letters and count the number of rows for that Number.
Number 1 has no Cs so it will not be returned.
Number 2 has no Cs so it will not be returned.
Number 3 has 1 C but also 1 B so it will not be returned.
Number 4 has all Cs so it will be returned.
Number 5 has all Cs (even though it's only 1) so it will be returned.
I was thinking of using GROUP BY in the query, but then I started reading about CONCAT and explode() so I'm even more lost than before.
Any assistance is appreciated. Thanks!
I want to return only the rows in a table that all have the same value in one column but only if they all have a specific value in another column.
So here's an example of the 2 columns in the table:
Number | Letter
1 | a
1 | a
2 | a
2 | b
3 | c
3 | b
4 | c
4 | c
5 | c
So I want to return all of the Numbers that have only C for all of their Letters and count the number of rows for that Number.
Number 1 has no Cs so it will not be returned.
Number 2 has no Cs so it will not be returned.
Number 3 has 1 C but also 1 B so it will not be returned.
Number 4 has all Cs so it will be returned.
Number 5 has all Cs (even though it's only 1) so it will be returned.
I was thinking of using GROUP BY in the query, but then I started reading about CONCAT and explode() so I'm even more lost than before.
Any assistance is appreciated. Thanks!
Last edited by a moderator: