我正在使用 Join 运算符检查表中的两个值,但它不起作用
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID= Category.CategoryID where ContentMaster.ContentTitle='%@' || ContentMaster.ContentTagText='%@' ",appDelegate.tagInput,appDelegate.tagInput];
如果我不使用运算符并在 where 子句中使用一个,那么它会显示结果。
像
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID= Category.CategoryID where ContentMaster.ContentTitle='%@'",appDelegate.tagInput];
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID= Category.CategoryID where ContentMaster.ContentTagText='%@'",appDelegate.tagInput];
任何想法如何解决这个问题,以便或运算符(operator)工作
最佳答案
在 SQL(尤其是 SQLite)中,运算符 ||
通常意味着字符串连接。
如果你想要逻辑 or
, 使用运算符 OR
.
关于iphone - OR 运算符在查询 sqlite iphone 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20066068/