I am planning to write an iOS app which uses SQLite as the backend. My database contains Vietnamese text such as "Hải Sơn". The users, being used to Google search, want to enter a search term like "hai son" in order to find the text above. I tried the following query:
SELECT * FROM towns WHERE title LIKE '%hai son%';
And I got 0 record. How do I make this to work? I know that Google and other search engines handle this case, so it can be done. I also don't want to make my users type the Vietnamese text with complete diacritical marks because not all the users know how to do so.
I looked at the sqlite3 documentation and looks like there are only three valid collation sequences: BINARY, NOCASE, and RTRIM. Am I missing something?.
My table was created with:
CREATE TABLE towns ( sid INTEGER PRIMARY KEY NOT NULL, title TEXT )
So far, I only used the sqlite3 command line to create the database, table, and import text from a CSV file.
My sqlite3 is at version 3.7.12
Alias gave me an idea: to create my own collating sequence. I will post a follow up if it works.
Try this:
SELECT * FROM towns WHERE title COLLATE UTF8CI LIKE '%hai son%';
Related to answer found here: How do I convert a column to ASCII on the fly without saving to check for matches with an external ASCII string?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With