node中mysql查询结果
作者:互联网
插入:
const mysql = require('mysql')
const con = mysql.createConnection({
host:'localhost',
user:'root',
password:'root',
port:3306,
database:'myblog'
})
con.connect()
let sql = `insert into blogs (title,content,createtime,author) values ('title1','content1',1607219354313,'dean');`
con.query(sql,(err,data)=>{
if(err){
console.error(err)
}
console.log(data)
})
查询:
let sql = `select * from blogs;`
修改:
let sql = `update blogs set title='my title1' where author='dean'`
删除
let sql = `delete from blogs where title='my title1'`
只有update操作返回的结果里changedRows:1
标签:node,err,blogs,mysql,查询,title1,let,sql 来源: https://blog.csdn.net/dyw3390199/article/details/110730802