Split by record Mysql

hi everyone I would like to process each record of a select query of a Mysql node through a function or function item, I’ll explain better: in mysql select I have 5 records of these records a field called Description is analyzed by the function with a split and the function I would like to create records with an id field of the Mysql query and a field with one of the data obtained from the split: ex: Mysql query id field = 1234, description field a_b_c; in the function I would like to have an output with: prumo record: field id = 1234, field description_split = a; second record: id field = 1234, description_spli field = c etc …

Sorry, I do not understand. Can you elaborate? Thanks.

The output of the Mysql is the one below?

   idfield: 1234,
   description field a_b_c
1 Like


var item=[];

var ok;

const newItems = [];
const newItems2 = [];
for (let ii=0;ii<items.length;ii++) {
   var myvar =$item(ii).$node["FunctionItem2"].json["description"];
   var parts=myvar.split("-");
   var auid=$item(ii).$node["FunctionItem2"].json["assigned_user_id"];
   var id=$item(ii).$node["FunctionItem2"].json["id"];
   var parent_id=$item(ii).$node["FunctionItem2"].json["parent_id"];

for (let i=2;i<parts.length-1;i++) {
  item[`var${i+1}`] = parts[i];
  items[0].json = {data:  [ {"Elemento": parts[i], "Prodotto": parts[0],"User Id":auid, "id":id , "parent_id":parent_id } ]};
  for (const item of  items[0].json.data) {
  newItems2.push({json: item});



return newItems2;

Glad that you figured it out. Have fun.

1 Like

in fact it is enough to reason and everything is resolved