On 23 Feb 2011, at 3:48pm, Mohit Sindhwani 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
I would not try to make each individual word of a name a row in a table. I think 'LIKE' is designed almost exactly for your problem: <http://www.sqlite.org/lang_expr.html#like> This means you can search on any component of the name. for instance, SELECT id,name FROM contacts WHERE name LIKE '%ell%' will find all the 'Kelly' entries and also all the 'Ella' entries. Similarly SELECT id,name FROM contacts WHERE name LIKE '%Simon Kelly%' Would return 'Simon Kelly Smith' and 'Simon Kelly Grant' and 'Eric Simon Kelly' and even 'Simon Kellyson' and 'Jossimon Kellysen'. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users