高手求助 分页出现小问题了
select top 10 project.proName,awards.commenderId,awards.alevel,awards.yearNumId,
awardsMoney.rank,awardsMoney.moneyz,awardsMoney.awardsTypeId
from (select ROW_NUMBER()
OVER( order by yearNumId desc)
AS 'RowNumber', project.proName,awards.commenderId,awards.alevel,awards.yearNumId,awardsMoney.rank,awardsMoney.moneyz,awardsMoney.awardsTypeId
from awards,project,awardsMoney
where awards.alevel>0 and awards.keyz = project.keyz
and awards.awardsTypeId=awardsMoney.awardsTypeId
and awards.alevel=awardsMoney.rank
and awards.yearNumId=1 and awards.commenderId =1
) as TT where RowNumber >0
这个语句错了
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "project.proName"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awards.commenderId"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awards.alevel"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awards.yearNumId"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awardsMoney.rank"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awardsMoney.moneyz"。
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "awardsMoney.awardsTypeId"。
应该怎么修改啊 我用单表查询 这种模式的分页没有问题多表就出这个问题 高手求助
------解决方案--------------------外面那一层肯定是找不到 你的几个表了
改成下面的
SQL code
SELECT TOP 10
proName , commenderId , alevel , yearNumId , rank , moneyz , awardsTypeId
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY yearNumId DESC) AS 'RowNumber' , project.proName , awards.commenderId , awards.alevel , awards.yearNumId ,
awardsMoney.rank , awardsMoney.moneyz , awardsMoney.awardsTypeId
FROM awards ,
project ,
awardsMoney
WHERE awards.alevel > 0
AND awards.keyz = project.keyz
AND awards.awardsTypeId = awardsMoney.awardsTypeId
AND awards.alevel = awardsMoney.rank
AND awards.yearNumId = 1
AND awards.commenderId = 1
) AS TT
WHERE RowNumber > 0
------解决方案--------------------
select top 10 project.proName,awards.commenderId,awards.alevel,awards.yearNumId,
awardsMoney.rank,awardsMoney.moneyz,awardsMoney.awardsTypeId
这里全部换成TT.xxx