多表inner join查询。
虽然看了好多,但调试还是出错。没办法,至少再次提问!
我是这样写的:
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
请问哪里出了问题?
------解决方案--------------------先在查询分析器里检查一下SQL语句是否有错!
------解决方案--------------------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& " ' ")
------解决方案--------------------换成这样写也是可以的,试试看:
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& " ' ")
------解决方案--------------------刚刚少了个 "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& " ' ")