I'm implementing a sqlite3 query which is as follows:
NSString *searchQry=[NSString stringWithFormat:@"SELECT id, title FROM ts_Gallary WHERE title LIKE '%%%@%%' OR location LIKE 开发者_如何转开发'%%%@%%' OR tags LIKE '%%%@%%' AND imageExistStatus = 1;",self.searchString, self.searchString, self.searchString];
All my OR conditions are working properly But AND part is not been Checked, as it return row which hane imageExistStatus = 0 too.
And i'm unable to figure out the problem, so please help me with this.
Thank You.
Try this:
SELECT id, title FROM ts_Gallary WHERE (title LIKE '%%%@%%' OR location LIKE '%%%@%%' OR tags LIKE '%%%@%%') AND imageExistStatus = 1;
basically in your original query AND is applied only to tags LIKE '%%%@%%'
condition.
精彩评论