简体   繁体   English

如何使SQL区分大小写

[英]How to make SQL case sensitive

I have an Access database set up on a domain hosting service. 我在域托管服务上设置了Access数据库。 I am connecting to it through SQL. 我通过SQL连接到它。 However, I need all of my queries to be case sensitive, and as far as I know the way the server is set up on the hosting service is it's NOT case sensitive. 但是,我需要所有查询都区分大小写,据我所知,服务器在托管服务上的设置方式是不区分大小写的。 Is there a certain command that I could use in my SQL which would make the query case sensitive? 是否有一些我可以在我的SQL中使用的命令会使查询区分大小写?

Do you need to set the entire DB to case sensitive, or is it just part of some queries. 您是否需要将整个数据库设置为区分大小写,或者它只是某些查询的一部分。 If it is a query term then you can use these to force case sensitive matching: 如果是查询字词,则可以使用这些来强制区分大小写的匹配:

StrComp("A","a",0)

The 0 in the method signature is to perform a binary comparison giving you the case sensitivity you want. 方法签名中的0是执行二进制比较,为您提供所需的区分大小写。 It returns an integer. 它返回一个整数。

WHERE StrComp('myText1', 'MYTeXt1', 0) = 0

Documentation 文档

I think you can add collate after the WHERE clause. 我认为你可以在WHERE子句后添加整理。

SELECT col FROM table  
WHERE col COLLATE Latin1_General_CS_AS = 'value'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM