ChickensDontClap
ChickensDontClap

Reputation: 2051

Select rows based on text matches with SQLite

I need to setup a SELECT query that will return rows based on matching strings in columns that have comma-delimited lists.

Here's an example of the data:

path               title            desc            type        feed_type   markets         tags
IMG_5639.jpg        Malta Title     description     photo       sheetfed    tobacco,education   gatefolds,accordian
IMG_5672.jpg        Malta Title     description     conceptual  inline      magazine        gatefolds,oversized
IMG_5689.jpg        Malta Title     description     conceptual  digital     non-profit      oversized
IMG_5691.jpg        Malta Title     description     photo       sheetfed    automotive      oversized,obtuse
IMG_5694.jpg        Malta Title     description     photo       inline      tobacco         postcard,oblong
IMG_5699.jpg        Malta Title     description     conceptual  digital     education       oversized,obtuse
IMG_5701.jpg        Malta Title     description     conceptual  sheetfed    service         postcard,oblong
01.jpg          Barcelona Title     barcelona       conceptual  sheetfed    service         diecut
02.jpg          Barcelona Title     barcelona       photo       inline      education       postcard,oblong
03.jpg          Barcelona Title     barcelona       photo       digital     associations        gatefolds,accordian

Upvotes: 0

Views: 231

Answers (2)

J. Polfer
J. Polfer

Reputation: 12481

Try Googling about the LIKE clause.

The comma-delimited bit shouldn't matter unless your user puts commas in their search query.

In which case, if you can change the database schema, I'd put each column of your CSV data into its own database column. Which will allow you to query individually on each column.

Upvotes: 0

Invincible
Invincible

Reputation: 422

 I think, you should normalized your data properly? A single column should never contain a comma seperated string of names.
otherwise in most cases you would not get proper output.

Upvotes: 2

Related Questions