I am using FMDB database in IOS. In my database I have a one column called tags.
Tags column have a comma separated Value like apple,banana,
. I want Title
column where my keyword matches. I want to know how to search comma separated value in table column Please help.
Asked
Active
Viewed 154 times
1
1 Answers
1
You need to use LIKE
operator, when you have a field data like apple,banana,...
you can add a ,
at the beginning and end of it like ,apple,banana,...,
that makes all tags between two commas. Now you can check it if it contains ,yourTag,
.
I'm not so familiar with FMDB, But I think below code can help you:
FMResultSet *rs = [db executeQuery:@"SELECT Title FROM yourTable WHERE ','+tags+',' LIKE ?",
[NSString stringWithFormat:@"%%%@%%", @"," + search_text + @","]];
-
1@viratpuar You can check the link for [`Like`](http://stackoverflow.com/q/9008682/4519059) and edit it as I described to achieve what you want ;). – shA.t Feb 09 '16 at 09:57
-
Thanks i get what i want ;) – viratpuar Feb 09 '16 at 10:03