Nodejs教程
Nodejs Mysql
Nodejs MongoDB
Nodejs 对比

Node.js MySQL查询记录

Node.js MySQL查询记录

示例
从表" employees"中检索所有数据。
在DBexample文件夹中创建一个名为select.js的js文件,其中包含以下数据。
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
database: "lidihuo"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM employees", function (err, result) {
if (err) throw err;
console.log(result);
});
});
现在打开命令终端并运行以下命令:
Node select.js
Node.js查询记录1
您还可以使用以下语句:
SELECT * FROM employees;
Node.js查询记录2
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4