I have a MySQL table with the following structure:

I want a query that would receive a group of uids (or a single uid) and then check for their existence in a closed group under a specific mid. If they exist, the query should return the mid under which they exist. For example in the table above:
('chuks.obima', 'crackhead') should return '2
('vweetah','crackhead') should return '1'
('vweetah','crackhead','chuks.obima') should return 3
('crackhead') should return an empty result
I think you need something like this:
EDIT: based on your second example, this is what you are looking for:
or you can just substitute last subquery with the number of elements you are looking for, e.g.
HAVING COUNT(distinct uid) = 2EDIT2: now i understand exactly what you are looking for. This should give you the correct results:
where the last count is equal to the number of elements you are looking for. This could be simplified like this:
If the group is to considered closed if all uid are under the same
seq, you also have to modify group by with:group by your_table.mid, your_table.seqand your select withSELECT distinct your_table.mid