Iphone 从xcode无法为sqlite执行DISTINCT关键字
-void readProductsFromDatabase{ //设置数据库对象 sqlite3*数据库Iphone 从xcode无法为sqlite执行DISTINCT关键字,iphone,xcode,uitableview,sqlite,Iphone,Xcode,Uitableview,Sqlite,-void readProductsFromDatabase{ //设置数据库对象 sqlite3*数据库 // Init the animals Array products = [[NSMutableArray alloc] init]; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { NS
// Init the animals Array
products = [[NSMutableArray alloc] init];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
NSLog(@"db opened");
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = "SELECT DISTINCT productname FROM iphone ";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
NSLog(@"inside sqlite3 prepare");
// Read the data from the result row
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
我的问题是
const char*sqlStatement=从iphone中选择不同的产品名称
这行没有执行,我使用的是sqlite3,
提前感谢,问题就在这一步
NSString*aName=[NSString stringWithUTF8String:char*sqlite3_column_textcompiledStatement,2]
用0代替2,这行不执行是什么意思?