Sqlite 查询不起作用
我正在尝试获取特定行类型的所有行详细信息。
Select * from MainTable where JOB1=@Paint
它不起作用。我尝试了更多选择,但没有成功。谁能告诉我 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);
I am trying to get all row details for a particular row type.
Select * from MainTable where JOB1=@Paint
It's not working. I tried with more options but not got succes. Can anyone tell me what is the correct format in Objective-C?
complete code is like
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 firefox 插件 SQLite 管理器来触发 SQLite 数据库的查询
https:// addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
您可以在程序中编写相同的查询。如果仍然没有运行,请发布您的代码片段。
you can fire queries for SQLite db using firefox addon SQLite manager
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
same query you can write in program. If still it is not running please post your code snippet.