Sqlite 查询不起作用

发布于 2024-11-09 08:31:00 字数 1586 浏览 0 评论 0原文

我正在尝试获取特定行类型的所有行详细信息。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎夜雨 2024-11-16 08:31:00

您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文