lundi 11 septembre 2017

i want a random array value to be thrown into my database, how? [duplicate]

  var sql = "INSERT INTO info (name, age, lastname) VALUES ?";
  var values = [
    ['Johny', '28', 'High'],
    ['Peeter', '39', 'Lowsta'],
    ['Amie', '25', 'pear'],
    ['Hanah', '27', 'Main']
  ];


  con.query(sql, [values], function (err, result) {

    console.log("Number of records inserted: " + result.affectedRows);
  });
})``;

i have this code but dont want to give it every value in my array but only 1 random one how do i do that? (right now i give it all the values in the array and i want to give it only one of them a that must be random)




Aucun commentaire:

Enregistrer un commentaire