Home > database >  One of the column in digital split into multiple lines
One of the column in digital split into multiple lines

Time:10-09

Under the table data according to the num digital split into multiple lines, such as the num of 2 will be become by, 01 for 3 will become 01,02,03
The original table
Code num
01 2
02 3
Results the following
The serial number code num2
1 01 01
2 01, 02
3 02 01
02 02
4 02 r
Test data
DROP TABLE IF the EXISTS ` test `;
The CREATE TABLE ` test ` (
` Id ` int (11), NOT NULL AUTO_INCREMENT,
` code ` varchar (255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
` num ` int (11) NULL DEFAULT NULL,
PRIMARY KEY (` Id `) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT CHARACTER SET==10 utf8 COLLATE=utf8_general_ci ROW_FORMAT=Dynamic;

INSERT INTO ` test ` VALUES (8 '01, 2);
INSERT INTO ` test ` VALUES (9, '02, 3);
  • Related