有如下三个表
表一:employe
No Name tel
1 张三 00000000
表二:nodes
No name tel
101 北京 11111111
表三:ordertrack
Order_id OperDT OperNode NextNode Operator Descr
1111 时间 101 102 1 1
其中 nodes.No=ordertrack.OperNode employe.No=ordertrack.Operator
通过查询 表三中的 Order_id 得到如下结果
Order_id OperDT nodes.name NextNode employe.name employe.tel
1111 时间 北京 102 张三 00000000
————————————————————————————————————
先看下我写的语句
Order_id=Request("Order_id")
strQuery = "SELECT * FROM (ordertrack as aa inner join nodes as bb on aa.OperNode = bb.No) inner join employe as cc on aa.Operator = cc.No WHERE Order_id='"&Order_id&"'"
以上语句查询无误,但是是用SELECT * ,所以显示结果的时候 nodes和employe中都有name和tel 字段,当rs("name")和rs("tel")时都显示的是employe表中的name和tel
————————————————————————————————————
所以我用别名进行区分,将* 换为具体字段并加以别名
strQuery = "SELECT ordertrack.Order_id, ordertrack.OperDT, ordertrack.OperNode, ordertrack.NextNode, ordertrack.Operator, ordertrack.Descr, nodes.name as bname, employe.name as cname, employe.tel as ctel FROM (ordertrack as aa inner join nodes as bb on aa.OperNode = bb.No) inner join employe as cc on aa.Operator = cc.No WHERE Order_id='"&Order_id&"'"
然后 读取的时候
rs("Order_id") rs("OperDT") rs("bname") rs("NextNode") rs("cname") rs("ctel")
bname cname ctel 采用别名进行读取
可是通不过
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[MySQL][ODBC 3.51 Driver][mysqld-4.1.22-community-nt]Unknown table 'ordertrack' in field list
/list.asp, 第 16 行
第16行是 Set rs = adoDataConn.Execute(strQuery)
请问这是什么错误?是SQL语句的问题吗?
请高手指教!多谢!着急,在线等!QQ 401703331 多谢多谢!