How To Convert Anki Tags to FieldsBy Roger Keays, 4 September 2010 |
How To Convert Anki Tags to FieldsPreviously I had been using anki tags to record the parts of speech (verb/noun/adjective etc) for the words I learn. However, as I have way too many tags and never filtered using those tags, I decided to create a POS field in my model. Converting the tags to fields was more difficult than it should have been because SQLite didn't play well using a subquery with a condition in my UPDATE statement.
My eventual workaround was to use the following SQL statement once for each tag I needed to convert. Perhaps you will find it useful. Each time you run the query you need to change the tag value in two places, and also the name of the new field if necessary.
update fields set value='noun'
where fieldModelId=(select id from fieldModels where name='POS')
and factId in
(select facts.id from tags
join cardTags on cardTags.tagId = tags.id
join cards on cardTags.cardId=cards.id
join facts on cards.factId=facts.id
where tag = 'noun');
How To Convert Anki Tags to Fields
About Roger Keays