0

In my application I take entry from user as :-

Name:- -------------------------
Favorite Fruit:-  a)
                  b)
                  c)
                     --------- Add More ----------

Then I want to save it into a Sqlite database. Now I provide user to type in edittext search like this:-

Search Fruit:- Apple,Banana

And then I want to query my database and Print the name of those who like atleast Apple and Banana.

Now my issue is how do I make my database columns to achieve results faster. Should I make two columns Name and FruitsLiked or something else. Because if I make only two colums then how do I search into database.

Thanks

Ankesh kumar Jaisansaria
  • 1,563
  • 4
  • 26
  • 44

1 Answers1

0

Create one table n two columns. First column is for name , second one comma separated list of fruits.

Then as db query use like keyword based query

Sush
  • 3,864
  • 2
  • 17
  • 35
  • So if suppose one row is NAME --- Mango,Pear,Banana,Orange,Apple and user search for apple,banana then will that be achieved using like keyword – Ankesh kumar Jaisansaria May 10 '16 at 09:39
  • Yes.. Like works like pattern matcher. I would rather suggest you to use only one column and handle strings. ( json my suggestion ) – Sush May 10 '16 at 09:43
  • Could you please help me framing query for this. I am not able to use LIke keyword in query. – Ankesh kumar Jaisansaria May 10 '16 at 11:36
  • 1. http://www.tutorialspoint.com/sqlite/sqlite_like_clause.html, 2. https://www.sqlite.org/lang_expr.html, 3.http://stackoverflow.com/a/12613978/793943 – Sush May 10 '16 at 11:44