Answer the question
In order to leave comments, you need to log in
How to make a selection based on the coincidence of one of the fields?
There is a table table of the form It is id | field_a | field_b
necessary to make a selection on the coincidence of one field, and so that there are more than one matches.
for example
id | field_a | field_b
1 | cats | 13
2 | cats | 15
3 | cats | 16
4 | dogs | 15
5 | dogs | 16
6 | birds | 13
7 | birds | 19
8 | birds | 14
cats
dogs
Answer the question
In order to leave comments, you need to log in
SELECT t1.field_a FROM table t1
JOIN table t2 ON (t1.field_b=t2.field_b) AND (t1.id <> t2.id)
GROUP BY t1.field_a
HAVING COUNT(t2.field_b) > 1
Select *
From
(Select field_a
From Table_1
Where field_b in (Select field_b as bb
From Table_1
group by field_b
Having count(field_a)>1)) as tmp
Group By tmp.field_a
Having count(field_a)>1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question