mercredi 15 avril 2015

How to search the database for a field which is a substring of the query by using sqlite

Problem description


I want to search for the query = Angela in a database from a table called Variations. The problem is that the database does not Angela. It contains Angel. As you can see the a is missing.




Searching procedure


The table that I want to query is the following:



"CREATE TABLE IF NOT EXISTS VARIATIONS (ID INTEGER PRIMARY KEY NOT NULL, ID_ENTITE INTEGER, NAME TEXT, TYPE TEXT, LANGUAGE TEXT);"


To search for the query I am using fts4 because it is faster than LIKE% especially if I have a big database with more than 10 millions rows. I cannot also use the equality since i am looking for substrings.



  1. I create a virtual table create virtual table variation_virtual using fts4(ID, ID_ENTITE, NAME, TYPE, LANGUAGE);

  2. Filled the virtual table with VARIATIONS insert into variation_virtual select * from VARIATIONS;

  3. The selection query is represented as follow: SELECT ID_ENTITE, NAME FROM variation_virtual WHERE NAME MATCH "Angela";




Question


What am I missing in the query. What I am doing is the opposite of when we want to check if a query is a subtring of a string in a table.


Aucun commentaire:

Enregistrer un commentaire