0
此查詢通過排序,篩選和分頁提供數據表。所有功能工作正常,直到我加入了INNER JOIN
,然後我得到:使用INNER JOIN和LIKE過濾的SQL分頁
The multi-part 'identifier "Types.Description" could not be bound
,如果我在查詢語句LIKE
工作結束除去第二WHERE
條款,但我失去分頁。我刪除了一些LIKE
子句來嘗試清理這個怪異的查詢。
SELECT *
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY TAG asc) AS RowNumber, *
FROM (
SELECT (SELECT COUNT(*) FROM Instruments) AS TotalDisplayRows, (SELECT COUNT(*) FROM Instruments) AS TotalRows, Instruments.Tag, Instruments.Location, Instruments.Description, Types.Description As TypeDesc, Manufacturer.Name, Lease.Name as LeaseName, Facility.Name as FacName
FROM Instruments
INNER JOIN Types ON Instruments.Type = Types.ID
INNER JOIN Manufacturer ON Instruments.Manufacturer = Manufacturer.ID
INNER JOIN Facility ON Instruments.Facility = Facility.ID
INNER JOIN Lease ON Instruments.Lease = Lease.ID
WHERE (Types.Description LIKE '%Cat%')
) RawResults
) Results
WHERE (Types.Description LIKE '%Cat%') AND RowNumber BETWEEN 1 AND 10
這使我我的解決方案。謝謝!看起來很簡單..很有意義。 – Mason