由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Get companies providing services
相关主题
help about SQL for ACCESSmysql doesn't support subquery still?
新手问个简单的SELECT问题how to make this query
aks a simple SQL questionWhy is EXISTS generally faster than IN clause?
请教关于下面这个sql code地解释一个看似简单的sql语句
[转载] database for Linux?感觉SQL里的
Re: recursive sql?To get the 2nd, 3rd, 4th largest value
求教(SQL/Access): Join两个query tables 出错Please Help! ORA-00918: column ambiguously defined
Codes Re: 求教: Join 两个query (data)请教一个SQL query该怎么写
相关话题的讨论汇总
话题: service话题: companies话题: get话题: services话题: providing
进入Database版参与讨论
1 (共1页)
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 的大作中提到】
: 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
3
Nice. Thanks a lot.
1 (共1页)
进入Database版参与讨论
相关主题
请教一个SQL query该怎么写[转载] database for Linux?
Remove duplicate from oracle tableRe: recursive sql?
包子请教query求教(SQL/Access): Join两个query tables 出错
Oracle SQL Tunning Problem!Codes Re: 求教: Join 两个query (data)
help about SQL for ACCESSmysql doesn't support subquery still?
新手问个简单的SELECT问题how to make this query
aks a simple SQL questionWhy is EXISTS generally faster than IN clause?
请教关于下面这个sql code地解释一个看似简单的sql语句
相关话题的讨论汇总
话题: service话题: companies话题: get话题: services话题: providing