I am currently working on c9 IDE and when I run the code below, it gives me errors. How do I get around this Issue?
app.js
var mysql = require("mysql");
var connection = mysql.createConnection({
host: 'localhost',
user: 'poream3387',
database: 'join_us'
});
var q = 'SELECT CURTIME() as time, CURDATE as date, NOW() as now';
connection.query(q, function (error, results, fields) {
if (error) throw error;
console.log(results);
});
connection.end();
command:
node app.js
error:
/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Parser.js:80 throw err; // Rethrow non-MySQL errors ^
Error: ER_BAD_FIELD_ERROR: Unknown column 'CURDATE' in 'field list' at Query.Sequence._packetToError (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14) at Query.ErrorPacket (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/sequences/Query.js:77:18) at Protocol._parsePacket (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:278:23) at Parser.write (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Parser.js:76:12) at Protocol.write (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:38:16) at Socket. (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:91:28) at Socket. (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:502:10) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) -------------------- at Protocol._enqueue (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:144:48) at Connection.query (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:200:25) at Object. (/home/ubuntu/workspace/app.js:12:12) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:389:7)
var q = 'SELECT CURTIME() as time, CURDATE() as date, NOW() as now';
– Jamie_D