34,590
社区成员
发帖
与我相关
我的任务
分享
select WarehouseType
from WAREHOUSE
where Facility = 'AA'
and Warehouse
= (select Warehouse
from WAREHOUSE_LOCATION
where ID
= (select PutAwayLocationID
from WORK_CENTER
where WorkCenter
= (select WorkCenter
from WIP_OPERATION
where WipOrderNo = 'BB'
and WipOrderType = 'CC')))
select WarehouseType
from WAREHOUSE
where Facility = 'AA'
and Warehouse
= (select Warehouse
from WAREHOUSE_LOCATION
where ID
= (select PutAwayLocationID
from WORK_CENTER
where WorkCenter
= (select top 1 WorkCenter
from WIP_OPERATION
where WipOrderNo = 'BB'
and WipOrderType = 'CC')))
[/quote]
连子查询为连接查询 然后在连接字段加索引
select WarehouseType
from WAREHOUSE
where Facility = 'AA'
and Warehouse
= (select Warehouse
from WAREHOUSE_LOCATION
where ID
= (select PutAwayLocationID
from WORK_CENTER
where WorkCenter
= (select top 1 WorkCenter
from WIP_OPERATION
where WipOrderNo = 'BB'
and WipOrderType = 'CC')))
SELECT WarehouseType
FROM WAREHOUSE w
INNER JOIN WAREHOUSE_LOCATION wl ON w.Warehouse = wl.Warehouse
INNER JOIN WORK_CENTER wc ON wl.id = wc.PutAwayLocationID
INNER JOIN WIP_OPERATION wo ON wc.WorkCenter = wo.WorkCenter
AND wo.WipOrderNo = 'BB'
AND wo.WipOrderType = 'CC'
WHERE w.Facility = 'AA'