You can use the table information information_schema.columns
separating the information as suggested in the answer to the question Split column into multiple rows (split).
Schema (Mysql v5.7)
CREATE TABLE shirts (
name VARCHAR(40),
size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
);
CREATE TABLE numeros (
numero int
);
INSERT INTO numeros(numero)
VALUES(1), (2), (3), (4), (5),
(6), (7), (8), (9), (10);
Query
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(REPLACE(REPLACE(c.column_type, 'enum(', ''), ')', ''), '''', ''), ',', n.numero), ',', -1) AS valor
FROM information_schema.columns c
CROSS JOIN numeros n
WHERE c.table_name = 'shirts'
AND c.column_name = 'size';
Resulting in
| valor |
| ------- |
| x-small |
| small |
| medium |
| large |
| x-large |
See working on DB Fiddle.
INFORMATION_SCHEMA COLUMNS
The COLUMNS
table provides information about Columns in Tables.
In free translation:
The table COLUMNS
provides information about table columns.