有三张表,表Product有字段ID,表Attribute有字段ID,表Product_Attribute_Mapping有字段ProductId、AttributeId,现在我要根据多个AttributeId查出Product,就是查询具有所有这些属性的产品,怎么搞?
解决方案 »
- Lg SQL Server 2005导入SQL Server 2000的数据
- 求一触发器
- 求一SQL语句
- 插入 语句 中 字符的问题
- 在执行存储过程中如果发生断电会怎么样?
- 安装sql server2005时,提示“无法启动SQL Server(MSSQLSERVER)服务 错误1053“和“sqlservr.exe[4076] 中发生未处理的win32异常”
- 如果从access表中分别取出奇数和偶数记录?在线等,谢谢
- win7里面,读取并显示sql图片问题
- 大家看看这个连接SQL的代码哪里错了?我在本机调试没问题,传到SERVER上却500错误
- C\S模式下的SQL server 2000 问题
- 几个count(*) 语句怎么在一个sql 中查询 且 效率高
- SQL CLR 事务嵌套帮助
from Product as a
where not exists(select 1 from Attribute as b where not exists(select 1 from Product_Attribute_Mapping where ProductId=a.ProductId and AttributeId=b.AttributeId))
inner join attribute c on b.attributeid=c.id
where c.属性 in(这里放属性列表)
select * from Product as a where not exists(select 1 from Attribute as b where not exists(select 1 from Product_Attribute_Mapping where ProductId=a.ID and AttributeId=b.ID))
a.id
from
Product a,Attribute b,Product_Attribute_Mapping c
where
a.id=c.ProductId
and
b.id=c.AttributeId
group by
a.id
having count(b.id)=(select count(AttributeId) from Product_Attribute_Mapping)