2012-10-06 132 views

回答

3

尝试转义SQL中的%字符,以使stringWithFormat知道不会尝试替换它们的值。像:

NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString]; 
+0

谢谢!有用 ! – malinchhan

1

替换代码查询与以下

NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString]; 
+0

谢谢,它与上面的答案一样! – malinchhan

+0

看看sc#re :-) – Vishal

相关问题