1 . 建表语句:
NSString *sqlCrTable = [NSString stringWithFormat:
@"CREATE TABLE IF NOT EXISTS '%@'('%@' INTEGER PRIMARY KEY AUTOINCREMENT,'%@' TEXT,'%@' TEXT)",rollTableName,Id,ADPicURL,flag];
2 . 插入数据:
NSString *sqlAdd = [NSString stringWithFormat:
@"INSERT INTO '%@' ('%@','%@') VALUES ('%@','%@')",flag,imageName,(i == 2)?@"FIXED":@"SCROLL"];
3 . 查询数据:
NSString *sqlQuery = [NSString stringWithFormat:
@"SELECT * FROM %@ order by ID limit %d",proTableName,kOnceCount]; // 只能这样取,不能用top, 一次取出几条数据
4 . 取出某值中间的数据:
NSString *sqlQuery = [NSString stringWithFormat:
@" SELECT * FROM %@ where ID > %d order by ID limit %d",self.lastIndex,kOnceCount];
语句资料可参考:http://www.yiibai.com/sqlite/sqlite_sub_queries.html