存在既更新,不存在就添加
INSERT INTO t (c1,c2,c3) VALUE ("新增的数据","","") ON DUPLICATE KEY UPDATE c2="更新的数据",c3=""
limit分页优化
SELECT * FROM t JOIN (select id from t limit 999999, 20) t2 ON t.id=t2.id
存在不插入,不存在插入
INSERT INTO 表名 (字段1,字段2,字段3)
SELECT "数据1","数据2","数据3" FROM DUAL
WHERE NOT EXISTS(SELECT 主键 FROM 表名 WHERE 字段4=条件 LIMIT 1)