select *from urunler where musteri like %ir%;
测试数据:
+---musteri---+---ID--+
+-------------+-------+
+---İrem------+---1---+
+---Kadir-----+---2---+
+---Demir-----+---3---+
返回结果:
Kadir
Demir
如果使用 %İr%
则 İrem 会返回,但 Kadir 和 Demir 不会返回。其他土耳其字符也有同样的问题,但没有任何确切的解决方案。我正在编写单声道 android。
[SQLiteFunction(Name = "TOUPPER", Arguments = 1, FuncType = FunctionType.Scalar)]
public class TOUPPER: SQLiteFunction
{
public override object Invoke(object[] args)
{
return args[0].ToString().ToUpper();
}
}
[SQLiteFunction(Name = "COLLATION_CASE_INSENSITIVE", FuncType = FunctionType.Collation)]
class CollationCaseInsensitive : SQLiteFunction {
public override int Compare(string param1, string param2) {
return String.Compare(param1, param2, true);
}
}
TOUPPER.RegisterFunction(typeof(TOUPPER));
以这种方式解决了,而且还使用了 mono c#'库,这是我需要做的 Android.Database.Sqlite.SQLiteDatabase
最佳答案
来自 SQL As Understood By SQLite ,“LIKE 和 GLOB 运算符”部分:
The LIKE operator is case sensitive by default for unicode characters that are beyond the ASCII range.
这意味着“İ”不同于“i”和“I”。
关于c# - 使用 LIKE 表达式时 SQLite 中的土耳其字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10349839/