Storing/Quering multiple value in SQLite
Posted
by
chmod
on Stack Overflow
See other posts from Stack Overflow
or by chmod
Published on 2012-09-21T09:32:14Z
Indexed on
2012/09/21
9:37 UTC
Read the original article
Hit count: 209
I'm trying to store a blooming season in month for each tree in SQLite3. Currently I had the field "month" then I store the month name in the field. For example
Tree Name Month
Tree1 Jan,Feb,Mar
Tree2 Nov,Dec,Jan
Tree3 Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
Tree4 Mar,Apr,Nov,Dec
Tree5 Jan,Feb,Mar,Apr
I'm not sure if this is the best way to store it, Any recommendation is appreciate.
Secondly, I need to perform a query where I enter in the month and it should return me the tree name that match the search criteria. For example
If I search for
"Jan"
the result should be Tree1,Tree2,Tree3,Tree5
"Jan,Feb,Mar"
the result should be Tree1,Tree3,Tree5
"Jan,Feb,Mar,Apr"
the result should be Tree5
"Sep,Oct,Nov,Dec"
the result should be none
Which SQL query do I have to use in order to obtain the above result?
Thanks
© Stack Overflow or respective owner