このクエリを sqlite マネージャーで直接テストすると、結果がよく表示されますが、iphone シミュレーターでテストすると、次のように表示されます。
この問題を解決するには?
%
SQL 内の文字をエスケープして、stringWithFormat
値を代入しようとしないようにします。お気に入り:
NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString];
コードクエリを次のように置き換えます
NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString];