多表inner join查询。

dawsons 2007-05-10 11:08:38
虽然看了好多,但调试还是出错。没办法,至少再次提问!
我是这样写的:
set rs=conn.execute("select a.*,b.depaname,c.cityname,c.areacode from [ctt_users] a inner join [ctt_department] b on a.userdepa=b.idexi inner join [ctt_city] c on a.usercity=c.id where a.username='"&username&"'")

调试后报告是这样的:

Microsoft JET Database Engine 错误 '80040e14'

语法错误 (操作符丢失) 在查询表达式 'a.userdepa=b.id inner join [ctt_city] c on a.usercity=c.id' 中。

UserFunc.asp,行 228
请问哪里出了问题?
...全文
351 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawsons 2007-05-10
  • 打赏
  • 举报
回复
弄明白了,我查其他的资料,inner不是那种写法。郁闷。
waitxing 2007-05-10
  • 打赏
  • 举报
回复
先在查询分析器里检查一下SQL语句是否有错!
班门弄斧 2007-05-10
  • 打赏
  • 举报
回复
刚刚少了个"and":
set rs=conn.execute("select a.*,b.depaname,c.cityname,c.areacode
from [ctt_users] a,[ctt_department] b,[ctt_city] c
where a.userdepa=b.idexi and a.usercity=c.id and a.username='"&username&"'")
班门弄斧 2007-05-10
  • 打赏
  • 举报
回复
换成这样写也是可以的,试试看:
set rs=conn.execute("select a.*,b.depaname,c.cityname,c.areacode
from [ctt_users] a,[ctt_department] b,[ctt_city] c
where a.userdepa=b.idexi and a.usercity=c.id a.username='"&username&"'")
falee 2007-05-10
  • 打赏
  • 举报
回复
set rs=conn.execute("select a.*,b.depaname,c.cityname,c.areacode from (([ctt_users] a inner join [ctt_department] b on a.userdepa=b.idexi) inner join [ctt_city] c on a.usercity=c.id) where a.username='"&username&"'")

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧