Justin Gould
Justin Gould

Reputation: 23

Select statement over multiple columns

I have an SQLite database with a table help with columns i_id, issue, url, steps, kw1, kw2, [...], kw12. kw1 - kw12 contain one word and can be null.

When I do:

sqlite> select issue,url,steps from help where kw1='adobe';

I get:

blank popup|blankpopup.html|S
missing pdfs|missingpdfs.html|S
printall not populating|printall.html|A

this is right. When I move to another keyword like 'ie' that is in multiple fields across kw1 - kw12, how do I do a select statement where instead of searching just kw1, it searches kw1 through to kw12?

I know what fields 'ie' is in. I have an Excel sheet of how the database is built but the people using the database don't.

Upvotes: 2

Views: 27603

Answers (1)

user15
user15

Reputation: 1052

If I understand right, you just need to use Or keyword and search thru all the kw-fields

sqlite> select issue,url,steps from help where kw1='ie' or kw2='ie' or kw3='ie' or kw4='ie' or kw5='ie' or kw6='ie' or kw7='ie' or kw8='ie' or kw9='ie' or kw10='ie' or kw11='ie' or kw12='ie';

Upvotes: 11

Related Questions