Sachit karki
Sachit karki

Reputation: 72

two data items in a single column, seperated by comma - SQLite query

please view the days header(sun,mon)

i have two item in the days column ("sun,mon"). For getting the subject according to the day, i have to fire a query by comparing the individual day, but there are two or more days in a single column. how could this be done in #Android?

Upvotes: 0

Views: 53

Answers (2)

Naren
Naren

Reputation: 9

SELECT *FROM mytable WHERE days LIKE '%sun%'

Upvotes: 0

Snild Dolkow
Snild Dolkow

Reputation: 6866

You want the SQL LIKE operator, which lets you use simple wildcards: % to match zero-or-more arbitrary characters, and _ to match exactly one arbitrary character.

So you'd do:

SELECT stuff FROM mytable WHERE days LIKE '%sun%'

This will be slow if you have a lot of rows in that table, though. If that's the case, you'll need a different table design.

Upvotes: 1

Related Questions