我使用join来获取sqlite表中的数据,这是我的查询
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID= Category.CategoryID LEFT JOIN Topic ON ContentMaster.TopicID=Topic.TopicID where ContentMaster.ContentTagText='%@' OR Category.CategoryName='%@' AND Topic.TopicName='%@'",appDelegate.tagInput,appDelegate.categoryName,appDelegate.topicName];
它工作正常,但我想使用此查询获取Category.CategoryName
和Topic.TopicName
以便如何获取以及何时获取该行,如下所示如何给出数字
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
{
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
Content *coffeeObj = [[Content alloc] initWithPrimaryKey:primaryKey];
coffeeObj.categoryID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,1)];
coffeeObj.topicID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,2)];
coffeeObj.contentType = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,3)];
coffeeObj.contentTitle = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,4)];
coffeeObj.contentAddedByUserID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,5)];
coffeeObj.contentDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,6)];
coffeeObj.contentFileName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,7)];
coffeeObj.contentSavedFileLocation = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,8)];
coffeeObj.contentSize = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,9)];
coffeeObj.contentAddedDateTime = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,10)];
coffeeObj.hiveletCode = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,11)];
coffeeObj.contentTagText = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,12)];
coffeeObj.views = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,13)];
coffeeObj.userName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,14)];
}}
如果我得到CategoryName
我必须写15或其他任何内容以及如何进入查询。