INSERT INTO field_data_field_taggings (entity_type, bundle, deleted, revision_id, language, delta, entity_id, field_taggings_tid)
SELECT "node" as entity_type, n.type AS bundle, 0 AS deleted, n.vid AS revision_id, "und" as language,
@i := IF(n.nid > @prev_nid, 0, @i + 1) AS delta, @prev_nid := n.nid AS entity_id,
tid as field_taggings_tid FROM taxonomy_index t, node n
JOIN (SELECT @prev_nid := NULL, @i := -1) v
WHERE n.nid=t.nid