select * from Bom_Bom where cpspcode like '510%'
and not exists(select * from Bom_Component where cpscode like '45%' and bomid=Bom_Bom.bomid)
1、每个成品(510开头)BOM中,都会包函45开头的半成品,现在要找出哪些成品BOM中,缺少45开头的半成品。
2、BOM_BOM 为主表,Bom_Component为子表。 cpspcode 为母件编码,cpscode为子件编码。
3、存货编码以510开头的为成品, 45开头的为缺少的半成品,正是要查找的