On 23 February 2011 15:48, Mohit Sindhwani <m...@onghu.com> wrote: > I am trying to build a simple contacts database in SQLite. > > I want people to be able to search starting with any word of the name. > > So, if I have: > 1,John Smith > 2,Simon James > 3,Simon Kelly Smith > 4,Jimmy Garcia > 5,Smith White Jones > 6,Simon Kelly Grant > ... > > If a user types "Smi", he should get the following results: > John Smith > Simon Kelly Smith > Smith White > > I am confused as to how to go about structuring this database. So far, > all I have is that I could split all the names into individual words and > then create a join table that joins every single word with every contact > that matches it. So, I would have something like: > Smith,1 > Smith,3 > Smith,5 > > This handles single-word cases... but if he types in "Simon Kelly", I'd > like to return: > Simon Kelly Smith > Simon Kelly Grant > > Any suggestions on how I should handle and model this requirement? > > Thanks, > Mohit. >
I suspect that FTS will do what you want (http://www.sqlite.org/fts3.html) Regards, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users