假设我有一个这样的表:
ID | title
–––|–––––––––––––––––––––––––––––––
1 | foxtrott uniform charlie kilo
2 | peter parker
3 | wulla wulla wulla
现在,我想创建一个动态表或视图,看起来像这样
phrase
–––––––––
charlie
foxtrott
kilo
parker
peter
uniform
wulla
这可能仅与MySQL有关吗?
最佳答案
因为我有点'老派',所以我的数据库中有一个整数表-ints(i) [0-9]
-
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
(id SERIAL PRIMARY KEY
,title VARCHAR(50) NOT NULL
);
INSERT INTO my_table VALUES
(1,'foxtrott uniform charlie kilo'),
(2,'peter parker'),
(3,'wulla wulla wulla');
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(title,' ',i+1),' ' ,-1) n FROM my_table,ints ORDER BY n;
+----------+
| n |
+----------+
| charlie |
| foxtrott |
| kilo |
| parker |
| peter |
| uniform |
| wulla |
+----------+
关于mysql - 使用MySQL从包含列值的所有单个单词的表列创建 View ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59142290/