Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite accent-insensitive search

Is there any way to do an accent-insensitive LIKE query in SQLite? For example, this query:

SELECT * FROM users WHERE name LIKE "Andre%"

would return:

André the Giant
Andre Agassi
etc.

I'm using Qt with QSqlDatabase if it makes any difference.

like image 688
laurent Avatar asked Dec 23 '12 06:12

laurent


People also ask

How do I make SQLite query case insensitive?

To be case insensitive on firstname , write this: select * from tbl where firstname='john' COLLATE NOCASE and lastname='doe' . It's specific to that one column, not the entire where clause.

Is SQLite case insensitive?

Case Sensitivity The important point to be noted is that SQLite is case insensitive, i.e. the clauses GLOB and glob have the same meaning in SQLite statements.

What is collate in SQLite?

Collating sequences are used by SQLite when comparing TEXT values to determine order and equality. You can specify which collation to use when creating columns or per-operation in SQL queries. SQLite includes three collating sequences by default.


1 Answers

Set up a collation using sqlite3_create_collation and then use it like this:

SELECT * FROM users WHERE name LIKE "Andre%" COLLATE NOACCENTS
like image 107
icktoofay Avatar answered Nov 16 '22 02:11

icktoofay