I need to update 3 rows in a table where they're connected with each other by same id(dailyId)..but I got the updated result like this
[ { firstItem: 'Breakfast', secondItem: 'Some' }, { firstItem: 'Breakfast', secondItem: 'Some' }, { firstItem: 'Breakfast', secondItem: 'Some' } ]
const meals =[ { firstItem: 'Lunch', secondItem: 'More' },
{ firstItem: 'Breakfast', secondItem: 'Some' },
{ firstItem: 'Snack', secondItem: 'None' } ]
meals.forEach((mealItem) => {
console.log(mealItem);
getConnection().query("UPDATE `dailydetailmeal` SET `mealName`='"+mealItem.firstItem+"',`quantity`='"+mealItem.secondItem+"' WHERE `dailyDetailId`='"+dailyId+"'", (err,result) => {
if (err) {console.log(err);
}
console.log(result);
})
})
mysql.createConnection({multipleStatments: true})