首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求解:SQL话语无法绑定与列明无效

2012-09-10 
求解:SQL语句无法绑定与列明无效SELECTUserReg.username AS userid, id, tneed, adddate, hot, verifyFROM

求解:SQL语句无法绑定与列明无效
SELECT UserReg.username AS userid, id, tneed, adddate, hot, verify
FROM (SELECT ROW_NUMBER() OVER (ORDER BY T .adddate DESC) AS Row, T .*
FROM TrainNeed T INNER JOIN
  UserReg ON userid = UserReg.id) TT
WHERE TT.Row BETWEEN 0 AND 10

这样写提示:
---------------------------
Microsoft SQL Server Management Studio
---------------------------
SQL 执行错误。

已执行 SQL 语句: SELECT UserReg.username AS userid, id, tneed, adddate, hot, verify FROM (SELECT ROW_NUMBER() OVER (ORDER BY T .adddate DESC) AS Row, T .* FROM TrainNeed T INNER JOIN UserReg ON userid = UserReg.id) TT WHERE TT.Row BETWEEN 0 AND 10
错误源: .Net SqlClient Data Provider
错误信息: 无法绑定由多个部分组成的标识符 "UserReg.username"。
---------------------------
确定 帮助  
---------------------------
SELECT username AS userid, id, tneed, adddate, hot, verify
FROM (SELECT ROW_NUMBER() OVER (ORDER BY T .adddate DESC) AS Row, T .*
FROM TrainNeed T INNER JOIN
  UserReg ON userid = UserReg.id) TT
WHERE TT.Row BETWEEN 0 AND 10

这样写提示列明无效。愁人~希望各位高手们帮忙看看。

[解决办法]
SELECT UserReg.username AS userid,

将UserRge去掉。
[解决办法]
改成下面

SQL code
SELECT TT.username AS userid, id, tneed, adddate, hot, verifyFROM (SELECT ROW_NUMBER() OVER (ORDER BY T .adddate DESC) AS Row, T .*,UserReg.username FROM TrainNeed T INNER JOIN  UserReg ON userid = UserReg.id) TTWHERE TT.Row BETWEEN 0 AND 10
[解决办法]
SQL code
--测试一下SELECT     T.username AS userid,     id,     tneed,     adddate,     hot,     verifyFROM (SELECT ROW_NUMBER() OVER (ORDER BY T.adddate DESC) AS Row, T.*FROM TrainNeed T INNER JOIN UserReg     ON T.userid = UserReg.id) TTWHERE TT.Row BETWEEN 0 AND 10
[解决办法]
SQL code
SELECT  username AS userid, id, tneed, adddate, hot, verifyFROM    (          SELECT  ROW_NUMBER() OVER ( ORDER BY T.adddate DESC ) AS Row ,                  T.*          FROM    TrainNeed T          INNER JOIN UserReg          ON      userid = UserReg.id        ) TTWHERE   TT.Row BETWEEN 0 AND 10 

热点排行