iphone - SQLite 语法(按引起错误的顺序排列)

标签 iphone sql sqlite

在寻找 SQLite 的语法帮助时,发生了一件非常奇怪的事情。我正在 iPhone 上运行查询。

这是失败的查询:(假设表是正确的,这在 firefox sqlite 插件中运行良好)

  select tcodes.DisplayOrder, StatusText, StatusCode  
    from tcodes 
    join tcode_transitions on tcode_transitions.available = tcodes.UNID 
   where StatusCode = 'AAA' 
order by tcodes.DisplayOrder

为了让它运行,我必须删除 order by 子句,这看起来有点奇怪。

这是电话:

// Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access

        int rtn = sqlite3_prepare_v2(database, [sql UTF8String], -1, &compiledStatement, nil);
        if(rtn != SQLITE_OK) {
            NSLog(@"SQL Error: %d",rtn);
            sqlite3_close(database);
        }
    }   

上面的rtn为==1,表示SQL错误。

同样,查询在手机之外运行得很好。 iPhone 上的 SQL 库是否可能有不同的 order by 语法?

最佳答案

  1. 使用sqlite3_errmsg (或sqlite3_errmsg16)以获取有关错误的更多信息。

  2. 尝试将 DisplayOrder 添加到 select 子句。 某些数据库要求 ORDER BY 子句中的所有列也出现在 SELECT 子句中。

关于iphone - SQLite 语法(按引起错误的顺序排列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3097122/

相关文章:

iphone - 如何确保 iOS 设备安全

sql - 快速获取 MySQL 中 2 列差异的方法

android - 在 SQLite (Android) 中为每个表创建单独的数据库的优势

iphone - 相机在手机间隙中无法使用

ios - SWRevealViewController 导航栏右键项目

mysql - 根据表 B 中的值从表 A 中获取不同行

java - fetch 返回不会转换为 Record 的记录类型

Android SQLite 原始查询参数

ios - 在核心数据中存储上下文属性的最佳方式?

ios - 在 UIWebView 中启用 Cookie