Created
September 11, 2018 09:50
-
-
Save 1000copy/2d145b83a2cb6dcb01cf95c391b387eb to your computer and use it in GitHub Desktop.
pph.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('mysql'); | |
var con = mysql.createConnection({ | |
host: "localhost", | |
user: "root", | |
password: "root1234", | |
database:"pph" | |
}); | |
con.connect(function(err) { | |
if (err) throw err; | |
console.log("Connected!"); | |
var date = '2018-09-11' | |
var sql = `select hour(sysc_time) as pp,count(*) as pph from tenant_access_records where date(sysc_time) = '${date}' group by hour(sysc_time);` | |
con.query(sql, function (err, result,fields) { | |
if (err) throw err; | |
console.log("Result: " ,fields); | |
for (var i = 0; i < result.length; i++) { | |
console.log(result[i].pp,result[i].pph) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment