开发者

Why AND condition is not beeen checked?

开发者 https://www.devze.com 2023-03-04 18:04 出处:网络
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 开发者_如何转开发

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消