Well, that is a little bit less easy, I thought that you wanted just to update a column. I have not completely succeeded either, but maybe I have found something useful.
First I created a table which contains all categories. I called that 'categories'. It has only one column: 'category'.
Then I created another table which I called 'export', with two colums, 'summary' and 'category'. You might want to add some more columns yourself like 'title' etc.
Now to populate the 'exports' table, I combined all rows in 'blog' with one row in 'categories' using the condition that the word in 'categories' is part of the string in 'blog'.
Code:
INSERT into EXPORT SELECT blog.summary,categories.category FROM blog
INNER JOIN categories ON summary REGEXP categories.category;
Now the contects of the blog table is:
Code:
mysql> select * from blog;
+-------------------------------------------------------+----------+
| summary | category |
+-------------------------------------------------------+----------+
| This is something which belongs in category technical | NULL |
| Another something which belongs in category technical | NULL |
| This is something which belongs in category social | NULL |
| Another social event description | NULL |
| technical | NULL |
+-------------------------------------------------------+----------+
5 rows in set (0.01 sec)
The categories
Code:
mysql> select * from categories;
+-----------+
| category |
+-----------+
| technical |
| social |
+-----------+
2 rows in set (0.00 sec)
And finally the combined result in exports:
Code:
mysql> select * from export;
+-------------------------------------------------------+-----------+
| summary | category |
+-------------------------------------------------------+-----------+
| This is something which belongs in category technical | technical |
| Another something which belongs in category technical | technical |
| technical | technical |
| This is something which belongs in category social | social |
| Another social event description | social |
+-------------------------------------------------------+-----------+
5 rows in set (0.00 sec)
Maybe there are smarter ways to perform this, and even write the category column back into the blog table, but this what I could come up with. After all it is just a one time use I assume.
jlinkels