简体   繁体   English

OR运算符无法在查询sqlite iphone中工作

[英]OR operator not working in query sqlite iphone

I am using Join operator to check two values in table but it does not work 我正在使用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];

If i do not use operator and use one in where clause then it shows result. 如果我不使用运算符,而在where子句中使用一个,那么它将显示结果。

like 喜欢

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];

Any idea how to fix this issue so that or operator works 任何想法如何解决此问题,使操作员或工作

In SQL (and SQLite in particular), operator || 在SQL(尤其是SQLite)中,运算符|| typically means string concatenation. 通常表示字符串连接。

If you want logical or , use operator OR . 如果要逻辑or ,请使用运算符OR

In sqlite just use or for logical or operation: sqlite仅用于or用于逻辑or操作:

SELECT * 
FROM ContentMaster 
LEFT JOIN  Category ON ContentMaster.CategoryID = Category.CategoryID 
WHERE ContentMaster.ContentTitle = '%@' OR ContentMaster.ContentTagText= '%@'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM