NodeJS MySql 执行多条sql语句

设置multipleStatements属性为true

 1 var connection =  mysql.createConnection( { multipleStatements: true } );
 2 
 3 connection.query('select column1; select column2; select column3;', function(err, result){
 4   if(err){
 5     throw err;
 6   }else{
 7     console.log(result[0]);       // Column1 as a result
 8     console.log(result[1]);       // Column2 as a result
 9     console.log(result[2]);       // Column3 as a result
10   }
11 });

 

参考项目:Github

 

posted @ 2017-12-13 12:44  提佰萬  阅读(5008)  评论(0编辑  收藏  举报