Okay, so I just found out that you can save and select on the JSON data type in MySQL.
I tried to follow user2458995's answer to a similar question as mine, (The difference is mine is with a key and the value is an array) I copied his exact code, created the table, put in the data from his insert SQL and tried his select, which gave me an error.
I modified the table here to show a sample of how the data will be stored in my example.
Basically I have this setup
CREATE TABLE my_table (id INT, data JSON);
INSERT INTO my_table VALUES (1, '{"hashtags": ["html", "php", "javascript"], "categories": [2,5,6]}'), (2, '{"hashtags": ["css", "jquery", "html"], "categories": [2,5,6]}')
If I want to select all the hashtags I can do it like this
SELECT data->>"$.hashtags" FROM my_table
But how do I select data like a where in?
I imagined something like this
SELECT * FROM `my_table` WHERE 'html' IN (data->>"$.hashtags")
It does execute, but it returns no rows. I also tried several other suggested ways but I can't get anything to work
SELECT * FROM `my_table` WHERE JSON_CONTAINS('html', '$.hashtags')
I thought this would be a really neat approach, but would it be smarter to just store each category/hashtag in a unique row with an FK id?
I hope someone can help me out here :)