ringa_lee
1、获取当前最大id,max(id)+1
INSERT INTO myTable (name,sort) SELECT 'Ali' as name,max(id)+1 as sort FROM myTable;
2、触发器CREATE TRIGGER t_afterinsert_on_myTable AFTER INSERT ON myTableFOR EACH ROWBEGIN
update myTable set sort=id where id=new.id;
END;然后插入的时候只要插入name值,INSERT INTO myTable (name) VALUES ('Ali');
当然是第一种比较简单。。。
1、获取当前最大id,max(id)+1
2、触发器
CREATE TRIGGER t_afterinsert_on_myTable
AFTER INSERT ON myTable
FOR EACH ROW
BEGIN
END;
然后插入的时候只要插入name值,INSERT INTO myTable (name) VALUES ('Ali');
当然是第一种比较简单。。。