const mysql = require('mysql2')
//创建连接
const connection = mysql.createConnection({
host: 'localhost',
port: 3306,
database: 'coderhub',
user: 'root',
password: 'root123.'
})
//编写mysql语句
const statement = `SELECT * FROM products WHERE price > ? AND score > ?`
//查询
connection.execute(statement, [6000, 7], (err, results, fields) => {
console.log(results)
})
执行结果;
image.png
网友评论