美文网首页
02-mysql2预处理语句

02-mysql2预处理语句

作者: 静昕妈妈芦培培 | 来源:发表于2021-03-13 18:35 被阅读0次
    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

    相关文章

      网友评论

          本文标题:02-mysql2预处理语句

          本文链接:https://www.haomeiwen.com/subject/kwgxcltx.html