Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-16 Thread Pontiac
On 05/15/2011 09:14 AM, Igor Tandetnik wrote: > Pontiac wrote: >> On 05/13/2011 03:15 PM, Trevor Borgmeier wrote: >>> SELECT categories FROM myTable WHERE (","||categories||",") LIKE "%,7,%"; >> Careful with how you have your like. As an added bonus, if you were to >> hunt for category 1, your st

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-15 Thread Trevor Borgmeier
on 5/14/11 9:02 AM Trevor Borgmeier wrote: > ...I was surprised when I tried a similar query with the same data in MySQL > and saw that it worked -- MySQL parsed the fields contents as if they were > separate items. I just wanted to correct my statement about my MySQL query -- I wasn't using IN,

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-15 Thread Igor Tandetnik
Pontiac wrote: > On 05/13/2011 03:15 PM, Trevor Borgmeier wrote: >> SELECT categories FROM myTable WHERE (","||categories||",") LIKE "%,7,%"; > > Careful with how you have your like. As an added bonus, if you were to > hunt for category 1, your statement would be LIKE "%,1,%" which would > retur

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-15 Thread Pontiac
On 05/13/2011 03:15 PM, Trevor Borgmeier wrote: > I have a database where a field's value is a comma separated list > indicating the basic categories the item belongs to. > > so if the "categories" field has a value of "1,8,15" > > I want to do a query like this: > > SELECT categories FROM myTable

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-14 Thread Trevor Borgmeier
Thanks for the responses. The three table approach you describe is what I normally use, but the export is coming from a filemaker database where they are stored this way so I thought I'd play with it as is. I was surprised when I tried a similar query with the same data in MySQL and saw that i

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-13 Thread Nico Williams
On May 13, 2011 8:17 PM, "BareFeetWare" wrote: > There is no function built into SQLite to convert a text string into a set (eg convert "1,8,15" into (1, 8, 15)), but such a function is not needed in this case. You need a better design of your database. SQLite is relational and you need to make yo

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-13 Thread BareFeetWare
On 14/05/2011, at 5:15 AM, Trevor Borgmeier wrote: > I have a database where a field's value is a comma separated list > indicating the basic categories the item belongs to. > > so if the "categories" field has a value of "1,8,15" > > I want to do a query like this: > > SELECT categories FROM

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-13 Thread Pavel Ivanov
> SELECT categories FROM myTable WHERE (","||categories||",") LIKE "%,7,%"; > > but I'm guessing LIKE isn't as efficient, and the query is more > awkward.  Any advise would be appreciated.  Thanks! This LIKE is the only way to get information from your table. But you can do it more efficiently by

Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-13 Thread Petite Abeille
On May 13, 2011, at 9:15 PM, Trevor Borgmeier wrote: > so if the "categories" field has a value of "1,8,15" Yep, it's a text column. Nothing relational about it. > Any advise would be appreciated. Normalize your design. ___ sqlite-users mailing lis

[sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-13 Thread Trevor Borgmeier
I have a database where a field's value is a comma separated list indicating the basic categories the item belongs to. so if the "categories" field has a value of "1,8,15" I want to do a query like this: SELECT categories FROM myTable WHERE "8" IN (categories); but it only finds records where