常用SQL技巧

不存在则插入,存在则更新(UPSERT) http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace/4330694#4330694

http://stackoverflow.com/questions/2717590/sqlite-upsert-on-duplicate-key-update

SQLite: INSERT OR REPLACE INTO files (id, number,name, detail, box_id) VALUES (1, “333”, “ss”,“sSSS”, 5);

MySQL: INSERT INTO files VALUES (:id, :number, :name, :detail, :box_id) ON DUPLICATE KEY UPDATE c=c+1