帮我看看这句SQL语句

来源:百度知道 编辑:UC知道 时间:2024/05/06 13:25:48
出错了 "select distinct inBillNo from [collection] where username='"&username&"' and states<6 and favtype='ord' order by date desc",conn2,1,1

出错了 "select distinct inBillNo from [collection] where username='"&username&"' and states<6 and favtype=ord order by date desc",conn2,1,1

修改:
1,"select distinct inBillNo from [collection] where username='"&username&"' and states<6 and favtype='ord' ",conn2,1,1
distinct关键字不能和order by语句一起用。

2,"select distinct inBillNo from [collection] where username='"&username&"' and states<6 and favtype=‘ord’ order by date desc",conn2,1,1
在SQL语句中,字符串要用引号括起favtype=‘ord’

date改为[date]试下

date 是SQL 的关键字!,不要用它给字段命名.

改为
"select distinct,inBillNo from [collection] where username='"&username&"' and states<6 and favtype='ord' order by date desc",conn2,1,1
或者
sql="select distinct,inBillNo from [collection] where username='"&username&"' and states<6 and favtype='ord' order by date desc"
rs.open sql,conn2,1,1

主要错误是你把distinct inBillNo之间的逗号落下了。
另外以防date和关键字冲突,把它加个[]吧。
sql="select distinct,inBillNo from [collection] whe