Best unofficial Apache Server developers community |
|
So I'm trying to search through a column where the string is a comma separated list of words with no spaces such as one,two,three,four and so on. Problem I'm facing is that I'm trying to match an exact word in the string. As of now I'm simply using %word% to find a match which of course works but the problem is it isn't exact in that if I searched for 'word' it would also match 'words', 'worded' and so on. So question is how can I search and get the exact word?
posted via StackOverflow
|
|
 
|
Append and prepend a comma to the string value in the column and then search it for your term which also has comma on either side of it:
and you search for
You don't have to alter ("tamper with") the database record itself. |
|
 
|
There is a design problem here. The database structure is not correct for what you're trying to achieve. Storing multiple values in a column and trying to match single values is possible with some other database as MySQL (with the SET type), but it's not on SQLite. So you could try all sort of weird string matching solution, but it won't be clean, and you will not be able to take advantage of SQLite optimizations. It will affect performance. What you could use instead is a separate |
|
 
|
If you don't want to mess with the string, you could modify your sql so that you are looking |