Here is the code
const add_friend = async (user_id, users) => {
try {
var data1 = [];
for (const user of users) {
data1 += [user,user_id,"Request Pending"];
}
await mysql.query('INSERT INTO friendship SET ?', [data1])
await mysql.end()
}
catch (err) {
throw err
So users is the list of all other user_id's which is coming as a parameter. user_id is a single id. What I am trying is to convert it into one list data1 with three values user_id1, user_id2, and request pending after that I want to update the table in one query only.
But the syntax is not correct. What should be the correct syntax. Please help.