我正在使用 SQLite.swift。 有什么方法可以在 SQLite 中执行不区分变音符号的 LIKE 查询?例如,这个查询:
SELECT * FROM users WHERE name LIKE "thu%"
会返回:
thử
thu
thư
etc.
来自 the documentation :
We can create custom collating sequences by calling
createCollation
on a database connection.try db.createCollation("NODIACRITIC") { lhs, rhs in return lhs.compare(rhs, options: .DiacriticInsensitiveSearch) }
We can reference a custom collation using the
Custom
member of theCollation
enumeration.restaurants.order(collate(.Custom("NODIACRITIC"), name)) // SELECT * FROM "restaurants" ORDER BY "name" COLLATE "NODIACRITIC"
在您的情况下,您可以在之后执行以下查询:
SELECT * FROM users WHERE name COLLATE NODIACRITIC LIKE 'thu%'
关于iOS - 如何使用 SQLite.swift 进行变音符号不敏感搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34051832/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |