0

我在正常情况下从两个表中选择数据,它工作正常,但如果我使用 where 子句,它不会返回任何内容。

这是查询

NSString *select =[NSString stringWithFormat:@"SELECT *from ContentMaster As ml LEFT JOIN ContentTagging As cat ON cat.ContentID = ml.ContentID where cat.ContenTagText= %@" , appDelegate.tagInput];

这是查询的NSLog

SELECT *from ContentMaster As ml LEFT JOIN ContentTagging  ON cat.ContentID = ml.ContentID where cat.ContenTagText= Tag1
4

1 回答 1

1

''在比较字符串时放入您的 ContentTagText

NSString *select =[NSString stringWithFormat:@"SELECT * from ContentMaster As ml LEFT JOIN ContentTagging As cat ON cat.ContentID = ml.ContentID where cat.ContenTagText= \'%@\'" , appDelegate.tagInput];

查询将是:

SELECT *from ContentMaster As ml LEFT JOIN ContentTagging  ON cat.ContentID = ml.ContentID where cat.ContenTagText= 'Tag1'

希望它会有所帮助。

于 2013-10-14T06:35:29.180 回答