0
我想获取特定行类型的所有行详细信息。Sqlite查询不起作用
Select * from MainTable where [email protected]
这不起作用。我尝试了更多的选择,但没有取得成功。任何人都可以告诉我Objective-C中正确的格式是什么?
完整的代码是这样
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
//const char *sqlStatement = "SELECT * FROM MainTable"; ??it is working
const char *sqlStatement = "SELECT * FROM MainTable where JOB1='Paint'";//but not this one
sqlite3_stmt *compiledStatement;
NSLog(@"query set");
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *job = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
NSString *image = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *tools = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString *materials = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
NSString *people = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)];
NSString *safety = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)];
NSLog(@"%@",job);
NSLog(@"image %@",image);
NSLog(@"tools %@",tools);
NSLog(@"materials %@",materials);
NSLog(@"people %@",people);
NSLog(@"safety %@",safety);
为什么它不起作用?你得到了什么错误?另外,请说明你如何约束这个查询,请... – sergio 2011-05-24 07:40:33