I have two tables as follows :
CREATE TABLE keyword_tbl
(
WORDS VARCHAR(100),
TOPIC VARCHAR(100)
);
INSERT INTO keyword_tbl
VALUES ('leaf', 'nature'), ('leaves', 'nature'),
('wind', 'nature'), ('knife', 'utensils'),
('knives', 'utensils'), ('calf', 'animal'),
('calves', 'animal')
CREATE TABLE content
(
CONTENT_ID VARCHAR(100),
DESCRIPTION VARCHAR(100)
);
INSERT INTO content
VALUES ('uuid1', 'leaves fall in autumn like leafs'),
('uuid2', 'the calf is playing in the leaf, the knife' ),
('uuid3', 'knives cutting the wind'),
('uuid4', 'he says hi'),
('uuid5', 'the calves running through the wind')
I want to be able to count the occurrences of each word per topic. My ideal output would look as follows.
| content_id | description | nature | utensils | animal |
|---|---|---|---|---|
| uuid1 | leaves fall in autumn like leafs | 2 | 0 | 0 |
| uuid2 | the calf is playing in the leaf, the knife | 1 | 1 | 1 |
| uuid3 | knives cutting the wind | 1 | 1 | 0 |
| uuid4 | he says hi | 0 | 0 | 0 |
| uuid5 | the calves running through the wind | 1 | 0 | 1 |
Explanation :
- For uuid1, we count
leavesandleafhence nature has a value of 2, - For uuid2, we count
calf,leaf,knifehence nature, utensils and animal have a count of 1, etc...
Is there a way for this to be done autonomously?

