S*******e 发帖数: 525 | 1 have a table listing all companies that provide a number of services such
as service1, service 2, ... service n. What is the best way to find all
companies that provide service n1, service n2, ... and service nm? Using a
number of subqueries with one embedded in another one seems to be a bad
approach. Do you have any better ideas? | B*****g 发帖数: 34098 | 2 what database?
what version?
anyway:
SELECT company
FROM your_table
WHERE service IN (service n1, service n2, ... and service nm)
GROUP BY company
HAVING COUNT(DISTINCT(service)) = m
【在 S*******e 的大作中提到】![](/moin_static193/solenoid/img/up.png) : have a table listing all companies that provide a number of services such : as service1, service 2, ... service n. What is the best way to find all : companies that provide service n1, service n2, ... and service nm? Using a : number of subqueries with one embedded in another one seems to be a bad : approach. Do you have any better ideas?
| S*******e 发帖数: 525 | |
|