SQLite accent-insensitive search

laurent picture laurent · Dec 23, 2012 · Viewed 9.8k times · Source

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.

Answer

icktoofay picture icktoofay · Dec 23, 2012

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

SELECT * FROM users WHERE name LIKE "Andre%" COLLATE NOACCENTS