Mysql
 sql >> Database >  >> RDS >> Mysql

Dividi la stringa in una riga

CREATE TABLE new_table
SELECT SUBSTRING(name,  1, 4) as field, class_code FROM old_table
UNION
SELECT SUBSTRING(name,  6, 4) as field, class_code FROM old_table
UNION
SELECT SUBSTRING(name, 11, 4) as field, class_code FROM old_table
UNION
SELECT SUBSTRING(year,  1, 4) as field, class_code FROM old_table
UNION
SELECT SUBSTRING(year,  6, 4) as field, class_code FROM old_table