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 -
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 |
+-----+-----+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.