Case sensitive searching in MS Access

跟風遠走 提交于 2021-01-28 05:04:20

问题


I have a query which searches rows in a database for matching strings. An example row may be:

This is a row which contains a String

The query that I am currently running is syntactically identical to

SELECT table.column FROM table WHERE table.column LIKE "*String*"

although it returns every row where the text "string" is found, regardless of case.

Does MS Access 2010 have any sort of case sensitive string comparator that I should be using instead of this?


回答1:


You will have to resort to VBA methods, I'm afraid. Fortunately, VBA methods can be used in JET SQLs (although performance might not be the best). The VBA Instr method allows you to specify the comparison mode (0 = binary = case-sensitive):

SELECT table.column FROM table WHERE INSTR(table.column, "String", 0) > 0



回答2:


I think LIKE '*String*' not LIKE "*String*"

See more LIKE condition in MS Access




回答3:


You can use Instr:

SELECT t.FieldName
FROM Table t
WHERE ((InStr(1,[FieldName],"aB",0)>"0"));


来源:https://stackoverflow.com/questions/33277646/case-sensitive-searching-in-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!