Sql like fuzzy search is case sensitive

Sql fuzzy query, Like the default is not case sensitive

When using the Like, how it supports the case?

upper, lower, only vaguely all content, not case sensitive content.

sqlite database text fields are case sensitive by default, but does not work alone in the fuzzy query.

The solution is: first before executing the query PRAGMA case_sensitive_like = 1; then execute database queries.

PRAGMA case_sensitive_like value, and may be 1/0, may also be provided to ON / OFF.

When turned on, there is a change would modify the database.

It is noteworthy that, after opened a case-sensitive, you need to add the Limit parameter query data

Direct access, no result:

select * from HanziList WHERE Pinyin like 'Q%'

 From the query log, we can see that the amount of data actually default query 0:

Add Limit parameter:

0,3 Limit Here, data indicating query data from the former three.

You can also use direct digital 3

 

reference:

Case sensitive and insensitive like in SQLite

Guess you like

Origin www.cnblogs.com/kybs0/p/12010112.html