主要还是在数据库内容同步的时候遇到的问题,服务器端也不标识变化发生,那客户端用sqilite3,本来就是要实现目的,udpate不成功,我就用insert。
自然想到去拿那个影响的record数目。
但看来大家多推荐replace,这个replace是不是要知道原来sql的primarykey的值啊,可我偷懒,没设置,全用了一个自增长的id,这下。。。
因为数据库建表时没有指定primary key,所以replace语句不正常.
option 1 would look like: //基本来说,目前的数据结构,表,应该可以做到用replace or insert。。。。。
- NSString * update =[NSString stringWithFormat:@"INSERT OR REPLACE INTO LIST (COUNT,NAME,DATE,IDNUM) VALUES (?,?,?)"];
option 2 would look like: //至于效率问题,我们需要找个同学测试下。。。。
先上下面的方案吧:)
为了减少网络流量,请问我可以只拿房间GUID和状态两个字段么,呵呵。。。。
The MIN/MAX optimization===============
Queries of the following forms will be optimized to run in logarithmic time assuming appropriate indices exist:
- SELECT MIN(x) FROM table;
- SELECT MAX(x) FROM table;
In order for these optimizations to occur,they must appear in exactly the form shown above - changing only the name of the table and column. It is not permissible to add a WHERE clause or do any arithmetic on the result. The result set must contain a single column. The column in the MIN or MAX function must be an indexed column.
所以我们的错误就在
@H_404_194@select @H_404_194@max(dd) @H_404_194@as x,@H_404_194@min(dd) @H_404_194@as y @H_404_194@fromdd@H_404_194@where state=4//本来测试没有看where,后来用了where发现不对了。这。。。。!