求解: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去掉。
[解决办法]
改成下面
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
[解决办法]
--测试一下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
[解决办法]
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