[英]Restart auto-increment on the next value of the another column
I want to make it in such a way that I get: 我想以这样一种方式使它得到:
Main | 主要| Column I want to reset on new main value 我想在新的主要价值上重置的列
1 | 100 1 | 101 1 | 102 1 | 103 1 | 104 2 | 100 2 | 101
You can use MyIsam engine to achieve this - 您可以使用MyIsam引擎来实现这一目标-
CREATE TABLE table1(
id1 INT(11) NOT NULL,
id2 INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id1, id2)
);
INSERT INTO table1 VALUES (1, NULL);
INSERT INTO table1 VALUES (1, NULL);
INSERT INTO table1 VALUES (2, NULL);
INSERT INTO table1 VALUES (2, NULL);
SELECT * FROM table1;
+-----+-----+
| id1 | id2 |
+-----+-----+
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 2 | 2 |
+-----+-----+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.