2 回答

TA貢獻(xiàn)2051條經(jīng)驗(yàn) 獲得超10個(gè)贊
var mysql = require('mysql');
var conn = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database:'nodejs',
port: 3306
});
conn.connect();
//查詢
// conn.query('SELECT * from user where name="wangzhiwei"', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
//新增
// conn.query('insert into user (username,password) values("huxiaona","123456")', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
//刪除
// conn.query('delete from user where username="wupeigui"', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
conn.query('update user set id="1" where username="huxiaona"',function(err,result){
if (err) {throw err};
console.log("修改數(shù)據(jù)成功");
})
conn.end();
- 2 回答
- 0 關(guān)注
- 628 瀏覽
添加回答
舉報(bào)