Suppose I have a table products
with
product | description |
---|---|
apple | yummy green fruit |
banana | nutritional yellow fruit |
Notice that the description
column may contain texts of arbitrary length (LONGTEXT). Now I want to get the table words
with all of the words from the column description
:
words |
---|
yummy |
green |
fruit |
nutritional |
yellow |
All of the answers I have found on StackExchange refer to splitting a string into several columns, not rows. How do I approach this problem?
EDIT: SELECT VERSION();
returns:
VERSION() |
---|
8.0.27 |
2
Answers
Based on Edit :
The following query shall work for LONGTEXT.
Here is the DBFIDDLE Demo.
The above code shall also remove any comma, quotes, hyphen, semicolon and other special characters before inserting individual words to a table.
If you are fine with duplicate entries (words) in a table; then you remove the distinct clause at start of query.
fiddle