[英]mssql and mysql case sensitive like
I should select all rows where a specific field starts with 'z' but not with 'Z' and the query should work both with mysql and mssql. 我应该选择特定字段以“ z”开头但不以“ Z”开头的所有行,并且查询应同时适用于mysql和mssql。
I can write the query separated for mssql and mysql, but I can't convert it to a unique query to work with both database. 我可以编写针对mssql和mysql分开的查询,但是不能将其转换为可同时用于两个数据库的唯一查询。
I don't know if it is possible at all. 我不知道是否有可能。 Any idea?
任何想法?
Use proper collation
. 使用适当的
collation
。 For example _BIN
or Case Sensitive. 例如
_BIN
或区分大小写。 You can find supported collations from following query. 您可以从以下查询中找到支持的归类。
SELECT * FROM sys.fn_helpcollations()
WHERE name LIKE 'sql%latin%CS%' or name like '%BIN';
and query like this 并像这样查询
select * from dbo.Categories
where CategoryName collate SQL_Latin1_General_CP1_CS_AS like 'be%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.