8
How could I perform a query ignoring words with letters that contain accents? Example of words:
Olá, é, Lógica, Pão
I tried using the command collate noaccents
as follows:
select c.* from Curso c
where c.Descricao like '%Logica%' collate noaccents;
However, I did not get any results, and it only works if I remove the accent from the word Lógica
. So how could I ignore the accents?
Minimal example
Commands to create the illustration example.
Table:
create table Curso(Descricao TEXT);
Insert:
insert into Curso(Descricao) values ('Lógica de Programação');
See working on SQL Fiddle.
you have to link to the accentuation library of your application. https://answall.com/questions/1785/70 - note that I left a code at the end with a simplified solution.
– Bacco
I wonder if it would be duplicate even, despite the title.
– Bacco
@Bacco I will take a look, but it seems to me a path that is not worth, maybe I opt for a normalization creating another column, I will have to research. I thought it was simple xD
– gato
simple it is, only it is a different path than you thought :D - usually nobody uses Sqlite "alone", and the application almost always has comparison function, just "link" with Sqlite
– Bacco
in particular, you have the sqlite3_create_collation() (and its variants) which is to use the function you want for comparison, usually you will point to the native function of comparison that already uses in other parts of your application (until everything is equal, the DB and the application)
– Bacco
@Bacchus to another question answers much of this question in a general way. Anyway I will implement otherwise, I will let the language do the work instead of Sqlite, so just link as you suggested. So if you want you can mark that question as a duplicate of the other and let the community decide, beauty?
– gato
If you think it is, your vote closes at once. I prefer that you think calmly what you think is best. About linking, read the documentation I mentioned, which is the most common way. Also, it has create_function if you need other "Accent insensitive" situations as well.
– Bacco
Possible duplicate of Sqlite android query() / like with accents and without
– rbz
@RBZ is not duplicated but related
– Sorack
@Sorack withdrawn! ;)
– rbz
@cat Any answers solved what was in doubt? Need something else to be improved? Think it is possible to accept it now?
– Maniero
@Maniero I need to access the database on another machine, the collation prevents me from accessing the bank using a customer, because I have to keep recreating it. I’m studying the possibility of using an algorithm
soundex
or similar, and create the keys to increase the accuracy of the research, but I am studying before making the decision.– gato