ms访问SQL LIKE查询问题与多个LIKE(VB -> ADODB)



我正在按页从数据库中查询一些练习。页面信息包含在练习的描述中。所以,练习描述是这样的:

p. 72. do this and that...
p.72. do this and the other thing...
p. 70. this is yet another exercise...

因此,为了适应 p 和实际数字之间缺少空格的情况,查询如下所示:

dbExerRecordSet.Filter = "ChapterID=100196 AND ExerciseType='School' AND (ExerciseDescription LIKE 'p. 72*' OR ExerciseDescription LIKE 'p.72*')"

但是我得到了这个错误:

ADODB.Recordset<br/><b>Description:</b> Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

所以我认为点字符有问题,因此我将查询转换为:

dbExerRecordSet.Filter = "ChapterID=100196 AND ExerciseType='School' AND (ExerciseDescription LIKE 'p[.] 72*' OR ExerciseDescription LIKE 'p[.]72*')"

但我仍然得到同样的错误。 这很奇怪。如果我删除OR及其之后的所有内容,则不会出错。如果我将 OR 更改为 AND,则不会出错(当然也没有找到练习)。

这是怎么回事?

提前谢谢。

编辑

dbExerRecordSet.Filter = "ChapterID=100196 AND ExerciseType='School' AND (ExerciseDescription LIKE 'p[.]*72*')"

上面没有抛出错误,但也找不到第 72 页中的两个练习。

编辑2:星号不是问题。我把它换成了%,它做了完全相同的事情

ADO 对LIKE通配符使用%*

最新更新