主鍵重復(fù)依然可以插入
+ (void)insertWithSetKeyName:(NSString *)keyName Value:(NSString *)value;
{
[self ?open];
NSString * sql = [NSString stringWithFormat:@"insert or ignore into PTBBSet values ('%@', '%@')", keyName, value];
sqlite3_exec(dbPoint, sql.UTF8String,NULL,NULL,NULL);
}
數(shù)據(jù)庫去重
select distinct name from table
數(shù)據(jù)庫模糊查詢
select * from table1 where field1 like ’%value1%’
數(shù)據(jù)庫多條件查詢 并且
select * from ?table?where name = '%@' and age = '%ld'
數(shù)據(jù)庫多條件查詢 或者
select * from? table where name = '%@' ?or?age = '%ld'
數(shù)據(jù)庫去重查詢
select ?distinct?name ?from ?table
查找并排序 ?asc正序? desc倒序
SELECT * FROM TABLE ORDER BY field1?DESC
查詢記錄總數(shù)
SELECT COUNT(*) FROM TABLE
查詢最大的
SELECT MAX(age) FROM TABLE
查詢最小的?
SELECT MIN(age) FROM? TABLE;
數(shù)據(jù)庫求和
select sum(field1) as sumvalue from table
數(shù)據(jù)庫取前10條
SELECT *FROM table LIMIT 10
數(shù)據(jù)庫跳過前面3條取3條數(shù)據(jù)
SELECT *FROM table LIMIT 6,3