I need to insert some data into a table, using the following code:
var query = 'INSERT INTO uso (id_usuario, id_tempo) VALUES ((SELECT id FROM usuario WHERE nome='Jose' LIMIT 1), (SELECT id FROM tempo WHERE timestamp=1505530800000 AND nome='dia_de_hoje' LIMIT 1));
INSERT INTO uso (id_usuario, id_tempo)VALUES ((SELECT id FROM usuario WHERE nome='Joao' LIMIT 1), (SELECT id FROM tempo WHERE timestamp=1505530800000 AND nome='dia_de_hoje' LIMIT 1))'
connection.query(query, function(err, results) {
if(err) throw err;
console.log(results);
});
But I'm getting the following error:
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO use (userid, time_id) VALUES ((SELECT id FROM user 'at line 3 at Query.Sequence._packetToError (
When I do this query directly on the server, insert
works normally.