在BOM表A中
成品料号 材料料号现在怎么样根据一份材料清单,查出这份材料清单是否有成品使用?或者说查出这份材料清单是哪一个成品使用?
成品料号 材料料号现在怎么样根据一份材料清单,查出这份材料清单是否有成品使用?或者说查出这份材料清单是哪一个成品使用?
解决方案 »
- 关于oracel字符串截取问题
- 这个动态交叉表怎么弄
- sql2000中,'ORIGINAL_LOGIN' 不是可以识别的 函数名。
- 数据库中两张表无法建立主外键关系!!!!!!
- 简单的 sql语句。查询列表
- sql查询语句中“-”的写法
- 求一条SQL语句?人员查询
- 怎么用DTS把oracle数据迁移值sqlserver2008
- 十万火急 希望高手帮助 SQL 根据两列查询不重复到数据
- 麻烦高手给讲解一下这段存储过程,duwamish中的!
- 将MS SQL中的数据导入access中,怎样先将access中的数据先删除掉?
- 求一条MySQL 转 SQL Server 的 select语句,超难(对于菜鸟来说)
你写的SQL语句,是反映这个清单里的材料被哪些成品使用.我的要求不是这样子,我要求的意思是也可以说:有哪个成品用的材料跟材料清单里的材料一模一样
create table ta(cp int,cl int) --成品组成表
create table tb(cl int) --材料清单表
insert ta
select 1,1
union select 2,2
union select 2,3
union select 3,1
union select 3,2
union select 3,3
union select 3,4
union select 4,1
union select 4,2insert tb
select 2
union select 3
select distinct cp as 符合成品号 from ta where
cp not in(select a.cp from ta a
where not exists(select 1 from
( select distinct b.cp,c.cl from (select cp,count(cl) as sl from ta group by cp) b,tb c
where b.sl=(select count(cl) from tb)) d
where d.cp=a.cp and d.cl=a.cl))
--删除测试数据
drop table ta
drop table tb符合成品号
-----------
2