带有SQL的ASP Classic - 缺少运算符

时间:2013-12-30 21:55:56

标签: sql asp-classic

我试图让这段SQL运作起来:

readsql = "SELECT * FROM [GROUP] INNER JOIN ubuser ON group.grp_USERID = ubuser.usr_ID INNER JOIN grpMembersLink ON grpMembersLink.grp_ID = [Group].grp_ID WHERE [Group].grp_ID = " & grpID & ""

然而它不起作用,我不确定为什么,任何人都可以看到我错过的错误吗?

查询表达式中的语法错误(缺少运算符)'group.grp_USERID = ubuser.usr_ID INNER JOIN grpMembersLink ON grpMembersLink.grp_ID = [Group] .grp_I'。

2 个答案:

答案 0 :(得分:4)

您已处于ASP模式,因此请使用字符串连接( with &

readsql = "SELECT * FROM post INNER JOIN ubuser ON post.pos_USERID = ubuser.usr_ID  WHERE usr_ID = '" & usrID & "' ORDER BY pos_date DESC, pos_time DESC"

但请记住,如果来自用户,您必须清理输入,否则您的代码将容易受到SQL注入攻击。

答案 1 :(得分:0)

您需要进行字符串连接,因此在&之前和之后添加<%=usrID%>