I am trying to query tableA
, joining or sub-querying on tableB
, where the count of matching rows from tableB
are less than 4.
Example:
tableA
+-------------------+
|columnA|columnB |
+-------------------+
|item1 |focaccia |
|item2 |spinach |
|item3 |goat cheese|
|item4 |beets |
+-------------------+
tableB
+-------------------+
|columnA|columnB |
+-------------------+
|blah1 |focaccia |
|blah2 |focaccia |
|blah3 |focaccia |
|blah4 |spinach |
|blah5 |goat cheese|
|blah6 |goat cheese|
|blah7 |goat cheese|
|blah8 |goat cheese|
|blah9 |goat cheese|
|blah10 |goat cheese|
|blah11 |beets |
|blah12 |beets |
|blah13 |beets |
|blah14 |beets |
|blah15 |beets |
|blah16 |beets |
|blah17 |beets |
+-------------------+
The desired result from my SELECT
from tableA
here would be:
+-------------------+
|columnA|columnB |
+-------------------+
|item1 |focaccia |
|item2 |spinach |
+-------------------+
... since the count of other matching items is greater than 4 each.
Is this possible?