如何使以下语句将第100行提取到第200行:
SELECT Offices.OfficeID, ContractsBooksCommodities.CommodityID
FROM ((((Offices
INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID)
INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)
INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum)
INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum)
INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum;
答案 0 :(得分:0)
这可能很慢:
SELECT Top 101 Offices.OfficeID, ContractsBooksCommodities.CommodityID
FROM ((((Offices
INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID)
INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)
INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum)
INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum)
INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum
WHERE Offices.OfficeID NOT IN (SELECT Top 99 Offices.OfficeID
FROM ((((Offices
INNER JOIN tbl_Sales ON Offices.CompanyID = tbl_Sales.CompanyID)
INNER JOIN ContractBooks ON tbl_Sales.CompanyID = ContractBooks.CompanyID)
INNER JOIN ContractsBooksAds ON ContractBooks.ContractNum = ContractsBooksAds.ContractNum)
INNER JOIN ContractsBooksBrands ON ContractsBooksAds.ContractNum = ContractsBooksBrands.ContractNum)
INNER JOIN ContractsBooksCommodities ON ContractsBooksBrands.ContractNum = ContractsBooksCommodities.ContractNum
ORDER BY Offices.OfficeID, ContractsBooksCommodities.CommodityID)
ORDER BY Offices.OfficeID, ContractsBooksCommodities.CommodityID
我不知道哪些字段使您的排序唯一,但这就是您所需要的,因为MS Access将返回匹配。