I want to select records from sqlite3 database by string matching. But if I use ‘=’ in the where clause, I found that sqlite3 is case sensitive. Can anyone tell me how to use string comparing case-insensitive?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
COLLATE NOCASEin yourSELECTquery:Additionaly, in SQLite, you can indicate that a column should be case insensitive when you create the table by specifying
collate nocasein the column definition (the other options arebinary(the default) andrtrim; see here). You can specifycollate nocasewhen you create an index as well. For example:create table Test ( Text_Value text collate nocase ); insert into Test values ('A'); insert into Test values ('b'); insert into Test values ('C'); create index Test_Text_Value_Index on Test (Text_Value collate nocase);Expressions involving
Test.Text_Valueshould now be case insensitive. For example:The optimiser can also potentially make use of the index for case-insensitive searching and matching on the column. You can check this using the
explainSQL command, e.g.: