From xcode not able to execute DISTINCT keyword for sqlite
Posted
by mac
on Stack Overflow
See other posts from Stack Overflow
or by mac
Published on 2010-03-12T06:14:21Z
Indexed on
2010/03/12
6:17 UTC
Read the original article
Hit count: 204
-(void) readProductsFromDatabase { // Setup the database object sqlite3 *database;
// 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);
}
My problem is
const char *sqlStatement = "SELECT DISTINCT productname FROM iphone ";
This line not executing ,i am using sqlite3, thanks in advance,
© Stack Overflow or respective owner