Copy values from taxonomy term field to new text field in content-type I have a content-type with a certain taxonomy term field that allows multiple values.

I don't need this field to be a taxonomy term field anymore, but just a simple text field. So, I want to "transform" the nature of the field.

I do know it is not possible and that I have to create a new text field and copy the values of my first field into my second through a custom php script.

But I hardly think that I'm going to need some help from you guys for the SQL query that will be a bit complex.


I need to recover all the term's names for each piece of content 
and, if there are several of them, concatenate them with a comma (for example), 
and then copy the result in the new text field before deleting the old taxonomy field.


The truth is I have no idea how to proceed. Can I run the query directly in PhpMyAdmin? Or in a PHP file? Do I need to use a simple SQL query or an EntityFieldQuery class? I'm not very familiar with this kind of stuff.

Thanks in advance for any clue...
According to me you can achieve it by doing something like:

Creating a PHP script which: Get all terms related to a node and then create a comma separated value for them and then store this as value of your new field in database.

You need to iterate over all nodes and the run following code to get all terms 

$result = db_query(
SELECT ttd.tid, ttd.vid, ttd.name, ttd.description, ttd.weight
FROM taxonomy_term_data AS ttd
INNER JOIN taxonomy_index ti ON ti.tid = ttd.tid
WHERE ti.nid= :nid
ORDER BY ttd.weight, ttd.name',array(':nid' =&gt;$node-&gt;nid));


Or you can use Drupal code as well for doing the same

$node = node_load(arg(1));
if ($node != NULL) {
$field = $node-&gt;field_my_vocabulary;
$lang= $node-&gt;language;
$terms_all = $field[$lang];
foreach ($terms_all as $term) {
$terms[] = $term['tid'];
}
return implode('+', $terms);
}


Now assign this vale to you new field.

The above code is not tested by me, but I hope it can do what you want with no/little modification :)